How to Remove Multiple Redis Cache

Tags: January 25, 2017 9:07 PM

Goals

Remove multiple Redis cache key using one liner command.

Steps

Assume keys that we want to delete are keys beginning with 'laravel:' prefix.

$ redis-cli KEYS 'laravel:*'
1) "laravel:featured:2bf46b40ed15"
2) "laravel:list:5509f57fdaef"
3) "laravel:list:2bf46b40ed15"
4) "laravel:list:e1bf5bfc2ab8"
5) "laravel:list-total-rec:adc81409d693"
6) "laravel:list-total-rec:e1bf5bfc2ab8"
7) "laravel:promotion-list:adc81409d693"
8) "laravel:list:d1f68333e3bb"
9) "laravel:list:c6a45c5cf5c5"

Just pipe the output above to xargs command. By default redis-cli will use raw format when STDOUT is not tty, which in case is true for xargs.

$ redis-cli KEYS 'laravel:*' | xargs redis-cli DEL
(integer) 9

Reference

Share on Facebook Twitter

1 comments:

abrialsaam said...

Casino Player Review – No Deposit Bonus, Slots, Free Spins
Casino Player 전라북도 출장샵 Review - Find out everything you 안양 출장샵 need to know about 김해 출장안마 our no deposit bonus, no deposit 창원 출장마사지 bonuses, 정읍 출장안마 free spins, loyalty program and much more!

Post a Comment