How can I determine all existing cache keys in a project built with Laravel framework?
Asked
Active
Viewed 3,400 times
1
-
Possible duplicate of [How to get list of all cached items by key in Laravel 5?](http://stackoverflow.com/questions/31791178/how-to-get-list-of-all-cached-items-by-key-in-laravel-5) – jszobody Mar 14 '16 at 21:32
-
which cache drive are you using? – Can Celik Mar 14 '16 at 22:32
-
@CanCelik File Cache. – Amr Mar 15 '16 at 01:46
-
This worked for me. http://stackoverflow.com/a/31791530/2951316 – Can Celik Mar 15 '16 at 19:48
2 Answers
1
There is a no way to do this via Laravel Cache library. But you can try to get the keys directly from the cache storage (filesystem, memcached, etc.)
-
1There is a no way via the Laravel Cache library... But you can do this directly from the storage service/files. – zsolt.k Mar 14 '16 at 22:52
0
Assuming you are using the (default) file cache driver, there is no way to get the cache keys, since they are not actually stored.
The key is used to derive a file path, but it's not actually stored.
From the source:
public function put($key, $value, $seconds)
{
$this->ensureCacheDirectoryExists($path = $this->path($key));
$result = $this->files->put(
$path, $this->expiration($seconds).serialize($value), true
);
if ($result !== false && $result > 0) {
$this->ensurePermissionsAreCorrect($path);
return true;
}
return false;
}

levi
- 23,693
- 18
- 59
- 73