使用PHP检查memcache集群中是否存在密钥

I'm debugging the caching layer of a PHP application. It uses a cluster of memcache servers to cache values. I want to verify that a specific object gets purged correctly.

My idea was to connect to the right memcache server with telnet and check manually if the key exists. I know the key that is passed to Memcache::set, but not which server to connect to. How do I know on which memcache server the data gets stored?

I just referenced the docs. Memcached clients hash the key to determine which sever to query. So, I guess Memcached IS sharded. You will probably have to look at the source of a client (or maybe the docs) to see how the hashing->sever is done. Otherwise you could just use a client from command line to query for the value.

If it's cluster than it's synchronizing data in al instances or have one centralized storage for data (internal realisation - not important for you). You will get data in all instances.

For future reference: I wrote a small python script that checks a list of memcache servers for a given key https://gist.github.com/721965