I am trying to test my cache was implemented with redis clustering (cluster by server not client). I have to flush redis every time I run a unit test. when I try to run flushdb command I got this error: Cannot use 'FLUSHDB' with redis-cluster. it seems that I can run flushdb command in cluster mode only when I set the slot but I do not know how to do it. (I have overridden redis wrapper of laravel so laravel is not the case If you learn me how to use predis I can adopt it with laravel)
how can I flush all redis nodes through predis?
For deleting by pattern:
redis-cli --raw keys "$PATTERN" | xargs redis-cli del
for example:
redis-cli KEYS "prefix:*" | xargs redis-cli DEL
For deleting all keys from one db:
redis-cli flushdb
For deleting all keys from all dbs:
redis-cli flushall
For cluster mode you need to use this bash script: https://gist.github.com/yaud/85e0382d26c189bdf84f0297cd54f479 to remove all nodes from master nodes (slave nodes will be synced)
© 2022 - 2024 — McMap. All rights reserved.