Skip to content

Instantly share code, notes, and snippets.

@carltondickson
Created February 28, 2017 11:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save carltondickson/1eec99ef26bef19e0ecf193e021ef97c to your computer and use it in GitHub Desktop.
Save carltondickson/1eec99ef26bef19e0ecf193e021ef97c to your computer and use it in GitHub Desktop.
Laravel 5.2 cache notes

Cache file name

  • Just an md5 of the cache key
  • Therefore not possible to identify key name from file name - md5 is one way

Cache directory name

  • Level 1 - First 2 characters of filename
  • Level 2 - Next 2 characters of filename
$storage = \Cache::getStore(); // will return instance of FileStore
$filesystem = $storage->getFilesystem(); // will return instance of Filesystem
$dir = (\Cache::getDirectory());
$keys = [];
foreach ($filesystem->allFiles($dir) as $file1) {
    if (is_dir($file1->getPath())) {
        foreach ($filesystem->allFiles($file1->getPath()) as $file2) {
            $keys = array_merge($keys, [$file2->getRealpath() => unserialize(substr(\File::get($file2->getRealpath()), 10))]);
        }
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment