class ActiveSupport::Cache::RedisCacheStore

def delete_matched(matcher, options = nil)

Failsafe: Raises errors.

See https://redis.io/commands/KEYS for more.

Use \ to escape special characters if you want to match them verbatim.

h[a-b]llo matches hallo and hbllo
h[^e]llo matches hallo, hbllo, ... but not hello
h[ae]llo matches hello and hallo, but not hillo
h*llo matches hllo and heeeello
h?llo matches hello, hallo and hxllo

Supports Redis KEYS glob patterns:

Cache Store API implementation.
def delete_matched(matcher, options = nil)
  instrument :delete_matched, matcher do
    unless String === matcher
      raise ArgumentError, "Only Redis glob strings are supported: #{matcher.inspect}"
    end
    redis.with do |c|
      pattern = namespace_key(matcher, options)
      cursor = "0"
      # Fetch keys in batches using SCAN to avoid blocking the Redis server.
      nodes = c.respond_to?(:nodes) ? c.nodes : [c]
      nodes.each do |node|
        begin
          cursor, keys = node.scan(cursor, match: pattern, count: SCAN_BATCH_SIZE)
          node.del(*keys) unless keys.empty?
        end until cursor == "0"
      end
    end
  end
end