Search code examples
ruby-on-railsrubymemcachedruby-on-rails-3.2dalli

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


How to delete a keys in memcached with 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

Not working with memcached. Any Ideas?


Solution

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

    In the Sweeper

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