How to remove keys in memcached using regex (using Dalli + Rails)
def expire_all expire_fragment(Regexp.new("/customers/customers")) expire_fragment(Regexp.new("/customers/customers\/")) expire_fragment(Regexp.new("/agreements/agreements")) expire_fragment(Regexp.new("/agreements/agreements\/")) end
Does not work with memcached. Any ideas?
install gem dalli-store-extensions https://github.com/defconomicron/dalli-store-extensions
In sweeper
expire_fragment /#{Regexp.escape(restaurant.id)}\/stocks*/
Memcached cannot iterate over its keys, so the validity period of a regular expression will not work. See documents .
Take a look at this for a potential workaround, although it is expensive.