The Cache class in laravel has methods such as get('itemKey') to retrieve items from the cache, and remember('itemKey', ['myData1', 'myData2']) to save items in the cache.
还有一个方法可以判断缓存中是否存在项:cache::has(‘MyKey’);
(在使用基于文件的缓存驱动程序时)有没有办法获得缓存中所有项目的列表?
例如,类似于"Cache::All()"的名称将返回:
[
'itemKey' => [
'myData1',
'myData2'
],
'myKey' => 'foo'
]
The only way I can think of doing this is to loop through all possible key names using the Cache::has() method. i.e. aaa, aab, aac, aad... but of course, this is not a solution.
I can't see anything in the documentation or the API that describes a function like this, but I don't think its unreasonable to believe that one must exist.