亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

How to get all Redis keys in cache in Laravel
P粉986860950
P粉986860950 2024-02-17 19:20:02
0
1
625

The caching facade in Laravel doesn't seem to allow you to get all keys currently cached in Redis.

I want to create an endpoint so that I can retrieve this information and know if my entries are working properly.

I tried using the Redis facade without success using the following commands and their respective errors

Redis::keys("*");

"Cannot use 'KEYS' with redis-cluster."


Redis::scan("cursor");

"Cannot use 'SCAN' with redis-cluster."

P粉986860950
P粉986860950

reply all(1)
P粉627027031

In Redis and cluster, if you have many keys, it is recommended to scan instead of keys. However, you should use it correctly. Try this approach.

use Illuminate\Support\Facades\Redis;

$cursor = '0'; // Start with initial cursor

do {
    // Scan for keys with current cursor
    list($cursor, $keys) = Redis::scan($cursor);

    foreach ($keys as $key) {
      echo "Key: $key\n";
   }
} while ($cursor !== '0'); // Continue scanning until cursor is '0'

refer to: Laravel and redis scanning

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template