0

Is it possible to list all memcachier keys of a Rails app? My app used just 3 keys and there are more than 30 on Memcachier app's page.

Thanks

hugalves
  • 271
  • 4
  • 15

2 Answers2

0

Use this script: https://gist.github.com/bkimble/1365005 And we can used in our apps~

fantaxy025025
  • 809
  • 8
  • 7
-1

You can't list all keys in memcached. memcached is a cache, not a database– if you need to consistently retrieve all keys, then memcached is probably not the tool you want to use.

With that in mind, 2 things:

  • It's actually possible to retrieve the first meg or so of keys: http://www.darkcoding.net/software/memcached-list-all-keys/ . Your prod server should not depend on this.

  • You could setup a system where you keep a key in memcached (named for example index), that has for its value a list of all the keys stored. Every time you're adding/deleting a key, you would also update index's list of keys. You can just retrieve index to get a list of all the keys. However, keep in mind that memcached can evict keys before they expire, so your app shouldn't rely on this technique for critical stuff.

Community
  • 1
  • 1
bitgarden
  • 10,461
  • 3
  • 18
  • 25