Memcached: Looping through a set of servers to delete a key. 
Cool way to make sure a key does not exist in a group of memcached servers. Handy when troubleshooting or when cached data needs a purge. Tested:
[aesteban@localhost ~]$ 
[aesteban@localhost ~]$ for i in {1..6};do ( echo 'delete events.slick-range') | nc server-${i}.example.com 11211; done;
NOT_FOUND
NOT_FOUND
NOT_FOUND
DELETED
NOT_FOUND
NOT_FOUND
[aesteban@localhost ~]$
[aesteban@localhost ~]$
[aesteban@localhost ~]$

Try adding a delay if the above doesn't seem to work:
[aesteban@localhost ~]$ 
[aesteban@localhost ~]$ for i in {1..6};do ( sleep 2; echo 'delete events.slick-range') | nc -d 2 server-${i}.example.com 11211; done;
NOT_FOUND
NOT_FOUND
NOT_FOUND
DELETED
NOT_FOUND
NOT_FOUND
[aesteban@localhost ~]$
[aesteban@localhost ~]$
[aesteban@localhost ~]$




BONUS (6/12/2019) - Find out the expiration date for a key:
(sleep 1; echo "stats cachedump 7 0"; sleep 1; echo "quit";) | nc www-server01.example.com  11211 | grep 'memc.sess.tpnm0jd8aottlturb0ml510sd0'


Increase/decrease the slab (seven) number as need until the key is found.

Comments
Comments are not available for this entry.
2024 By Angel Cool