Laravel 中的緩存外觀似乎不允許您獲取當前緩存在 Redis 中的所有鍵。
我想創(chuàng)建一個端點,以便我可以檢索此信息并了解我的條目是否正常工作。
我嘗試使用 Redis 外觀,但使用以下命令及其各自的錯誤沒有成功
Redis::keys("*"); "Cannot use 'KEYS' with redis-cluster." Redis::scan("cursor"); "Cannot use 'SCAN' with redis-cluster."
在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'