How to get list of all cached items by key in Laravel 5?

前端 未结 5 813
旧时难觅i
旧时难觅i 2021-02-19 10:01

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 cach

5条回答
  •  南笙
    南笙 (楼主)
    2021-02-19 10:55

    In 'yourKeyGoesHere' you can insert a string used as same as a like with a * or insert directly the exactly key.

     $redis = Cache::getRedis();
     $a_keys = $redis->keys("*yourKeyGoesHere*");
     foreach ($a_keys as $key){
        //Your Action ...
        //For example forget key
        $redis->del($key);
     }
    

提交回复
热议问题