How to remove keys in memcached with regex (using Dalli + RoR).

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?

+5
source share
2 answers

install gem dalli-store-extensions https://github.com/defconomicron/dalli-store-extensions

In sweeper

expire_fragment /#{Regexp.escape(restaurant.id)}\/stocks*/
+3
source

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.

+3
source

All Articles