class AnyCache::Adapters::RedisStore
@api private @since 0.1.0
Public Class Methods
supported_driver?(driver)
click to toggle source
@param driver [Object] @return [Boolean]
@api private @since 0.1.0
# File lib/any_cache/adapters/redis_store.rb, line 13 def supported_driver?(driver) AnyCache::Drivers::RedisStore.supported_source?(driver) end
Public Instance Methods
read(key, **options)
click to toggle source
@param key [String] @option raw [Boolean] @return [Object]
@api private @since 0.1.0
# File lib/any_cache/adapters/redis_store.rb, line 26 def read(key, **options) raw = options.fetch(:raw, false) value = get(key, raw: true) raw ? value : detransform_value(value) end
read_multi(*keys, **options)
click to toggle source
@param keys [Array<String>] @param options [Hash] @return [Hash]
@api private @since 0.3.0
# File lib/any_cache/adapters/redis_store.rb, line 39 def read_multi(*keys, **options) # NOTE: cant use Redis::Store#mget cuz it has some marshalling errors :( Hash[keys.zip(keys.map { |key| read(key, **options) })] end
write(key, value, **options)
click to toggle source
@param key [String] @param value [Object] @option expires_in [NilClass, Integer] Time in seconds @option raw [Boolean] @return [void]
@api private @since 0.1.0
# File lib/any_cache/adapters/redis_store.rb, line 52 def write(key, value, **options) expires_in = options.fetch(:expires_in, NO_EXPIRATION_TTL) raw = options.fetch(:raw, false) value = transform_value(value) unless raw expires_in ? setex(key, expires_in, value, raw: true) : set(key, value, raw: true) end
write_multi(entries, **options)
click to toggle source
@param entries [Hash] @option raw [Boolean] @return [void]
@api private @since 0.3.0
# File lib/any_cache/adapters/redis_store.rb, line 66 def write_multi(entries, **options) raw = options.fetch(:raw, false) entries = transform_pairset(entries) unless raw mset(*entries.to_a.flatten!, raw: true) end