Sha256: 4445d7aa6db0e67d7bc09081be7bd2c9cb388e2f54a1713a4bb4e23d07a0a3d7
Contents?: true
Size: 1.26 KB
Versions: 1
Compression:
Stored size: 1.26 KB
Contents
require_relative "base" module ActiveCachedResource module CachingStrategies class ActiveSupportCache < Base def initialize(cache_store) super() @cache_store = cache_store end protected def read_raw(key) @cache_store.read(key) end def write_raw(key, compressed_value, options) successful_write = @cache_store.write(key, compressed_value, options) update_master_key(key, options) if successful_write successful_write end def delete_raw(key) @cache_store.delete(key) end def clear_raw(prefix) existing_keys = @cache_store.read(prefix) return if existing_keys.nil? existing_keys.add(prefix) @cache_store.delete_multi(existing_keys.to_a) # Redis implementation does not work with Sets end private # Updates the `master` key, which contains keys for a given prefix. def update_master_key(key, options) prefix, _ = split_key(key) existing_keys = @cache_store.read(prefix) || Set.new existing_keys.add(key) # Maintain the list of keys for twice the expiration time @cache_store.write(prefix, existing_keys, expires_in: options[:expires_in]) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
active_cached_resource-0.1.8 | lib/active_cached_resource/caching_strategies/active_support_cache.rb |