Class: AnyCache::Adapters::RedisStore Private

Inherits:
Redis
  • Object
show all
Defined in:
lib/any_cache/adapters/redis_store.rb

Overview

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

Since:

  • 0.1.0

Constant Summary

Constants inherited from Redis

AnyCache::Adapters::Redis::DEAD_TTL, AnyCache::Adapters::Redis::DEFAULT_INCR_DECR_AMOUNT, AnyCache::Adapters::Redis::DELETE_MATCHED_BATCH_SIZE, AnyCache::Adapters::Redis::DELETE_MATCHED_CURSOR_START, AnyCache::Adapters::Redis::NO_EXPIRATION_TTL

Instance Attribute Summary

Attributes inherited from Basic

#driver

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Redis

#clear, #decrement, #delete, #delete_matched, #exist?, #expire, #fetch, #fetch_multi, #increment, #persist

Methods inherited from Basic

#clear, #decrement, #delete, #delete_matched, #exist?, #expire, #fetch, #fetch_multi, #increment, #initialize, #persist

Constructor Details

This class inherits a constructor from AnyCache::Adapters::Basic

Class Method Details

.supported_driver?(driver) ⇒ Boolean

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.

Parameters:

  • driver (Object)

Returns:

  • (Boolean)

Since:

  • 0.1.0



13
14
15
# File 'lib/any_cache/adapters/redis_store.rb', line 13

def supported_driver?(driver)
  AnyCache::Drivers::RedisStore.supported_source?(driver)
end

Instance Method Details

#read(key, **options) ⇒ Object

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.

Parameters:

  • key (String)
  • options (Hash)

Returns:

  • (Object)

Since:

  • 0.1.0



26
27
28
29
30
# File 'lib/any_cache/adapters/redis_store.rb', line 26

def read(key, **options)
  raw = options.fetch(:raw, true)

  get(key, raw: raw)
end

#read_multi(*keys, **options) ⇒ Hash

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.

Parameters:

  • keys (Array<String>)
  • options (Hash)

Returns:

  • (Hash)

Since:

  • 0.3.0



38
39
40
41
# File 'lib/any_cache/adapters/redis_store.rb', line 38

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) ⇒ 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)
  • expires_in (Hash)

    a customizable set of options

Since:

  • 0.1.0



50
51
52
53
54
55
# File 'lib/any_cache/adapters/redis_store.rb', line 50

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

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

#write_multi(entries, **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:

  • entries (Hash)
  • options (Hash)

Since:

  • 0.3.0



63
64
65
# File 'lib/any_cache/adapters/redis_store.rb', line 63

def write_multi(entries, **options)
  mset(*entries.to_a.flatten!, raw: true)
end