lib/manage_cache.rb
def delete_cache_w_regexp(key_name)
      specs = self.class.cache_keys_specs[key_name]

      regexp = specs[:regexp].inject([]) do |m, (k,v)| 
        redis_store = Rails.cache.class.name == "ActiveSupport::Cache::RedisStore"
        m << "#{k}=#{redis_store ? '*' : v}" 
      end.join('-')

      key = prepare_cache_key(key_name)
      Rails.cache.delete_matched("#{Regexp.escape(key)}-#{regexp}")
    end
def delete_cache_w_regexp(key_name)
      specs = self.class.cache_keys_specs[key_name]

      regexp = specs[:regexp].inject([]) do |m, (k,v)| 
        redis_store = Rails.cache.class.name == "ActiveSupport::Cache::RedisStore"
        m << "#{k}=#{redis_store ? '*' : v}" 
      end.join('-')

      key = prepare_cache_key(key_name)
      Rails.cache.delete_matched("#{Regexp.escape(key)}-#{regexp}")
    end
def delete_cache_w_regexp ( key_name ) specs = self . class . cache_keys_specs [ key_name ] regexp = specs [ :regexp ] . inject ( [ ] ) do | m , ( k , v ) | redis_store = Rails . cache . class . name == "ActiveSupport::Cache::RedisStore" m << "#{k}=#{redis_store ? '*' : v}" end . join ( '-' ) key = prepare_cache_key ( key_name ) Rails . cache . delete_matched ( "#{Regexp.escape(key)}-#{regexp}" ) end
Opts added to cache_key_for will be suffixed to the rest of
 the cache_key.
 For these opts to take effect on cache management (e.g. deletion)
 use `regexp: { opts_key: "matcher_string" , .... }
 e.g.:

 in the paginated index view:

   <% cache @users.last.try(:cache_key_for, :users_index, page: params[:page]) do %>

 in the model:

   class User < ActiveRecord::Base
     manage_cache_for users_index: {
                        class_eval: { max_up: "maximum(:updated_at)"}
                        regexp:     { page: "\\d+" }
                      }

 be aware, that the matcher_string has to be escaped (e.g. "\\d+" instead of "\d+")!
Opts added to cache_key_for will be suffixed to the rest of the cache_key . For these opts to take effect on cache management ( e . g . deletion ) use regexp : { opts_key : matcher_string .... } e . g . :