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

獲取Laravel中緩存中的所有Redis鍵的方法
P粉986860950
P粉986860950 2024-02-17 19:20:02
0
1
627

Laravel 中的緩存外觀似乎不允許您獲取當前緩存在 Redis 中的所有鍵。

我想創(chuàng)建一個端點,以便我可以檢索此信息并了解我的條目是否正常工作。

我嘗試使用 Redis 外觀,但使用以下命令及其各自的錯誤沒有成功

Redis::keys("*");

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


Redis::scan("cursor");

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

P粉986860950
P粉986860950

全部回復(1)
P粉627027031

在Redis、集群中,如果你有很多key,建議掃描而不是key。 但是,您應該正確使用它。嘗試使用這種方式。

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'

參考: Laravel 和 redis 掃描

最新下載
更多>
網(wǎng)站特效
網(wǎng)站源碼
網(wǎng)站素材
前端模板