国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

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

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