Method: AnyCache::Adapters::Redis#write

Defined in:
lib/any_cache/adapters/redis.rb

#write(key, value, **options) ⇒ void

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.

Parameters:

  • key (String)
  • value (Object)
  • raw (Hash)

    a customizable set of options

  • expires_in (Hash)

    a customizable set of options

Since:

  • 0.1.0



97
98
99
100
101
102
103
# File 'lib/any_cache/adapters/redis.rb', line 97

def write(key, value, **options)
  raw = options.fetch(:raw, false)
  expires_in = options.fetch(:expires_in, NO_EXPIRATION_TTL)
  value = transform_value(value) unless raw

  expires_in ? setex(key, expires_in, value) : set(key, value)
end