Class: AboutYou::SDK::CacheProvider::Dalli
- Inherits:
-
Object
- Object
- AboutYou::SDK::CacheProvider::Dalli
- Defined in:
- lib/AboutYou/CacheProvider/dalli.rb
Overview
This class is used as an interface for cache operations. It is used when caching with Dalli.
- author
-
Collins GmbH & Co KG
Instance Attribute Summary collapse
-
#client ⇒ Object
an instance of the cache client.
Instance Method Summary collapse
-
#delete(key) ⇒ Object
This method is used for deleting cache entries with Dalli.
-
#exists(key) ⇒ Object
This method is used for checking whether a cache entry exists or not with Dalli.
-
#get(key) ⇒ Object
This method is used for getting cache entries with Dalli.
-
#initialize(client) ⇒ Dalli
constructor
the Constructor for the Dalli class.
-
#set(key, value, duration) ⇒ Object
This method is used for setting new cache entries with Dalli.
Constructor Details
#initialize(client) ⇒ Dalli
the Constructor for the Dalli class
-
Args :
-
client
-> an instance of Dalli::Client
-
-
Returns :
-
Instance of AboutYou::SDK::CacheProvider::Dalli
-
28 29 30 |
# File 'lib/AboutYou/CacheProvider/dalli.rb', line 28 def initialize(client) self.client = client end |
Instance Attribute Details
#client ⇒ Object
an instance of the cache client.
17 18 19 |
# File 'lib/AboutYou/CacheProvider/dalli.rb', line 17 def client @client end |
Instance Method Details
#delete(key) ⇒ Object
This method is used for deleting cache entries with Dalli.
-
Args :
-
key
-> The key of the cache entry
-
-
Returns :
-
True/False determining whether the deletion was successful or not
-
69 70 71 |
# File 'lib/AboutYou/CacheProvider/dalli.rb', line 69 def delete(key) client.delete(key) end |
#exists(key) ⇒ Object
This method is used for checking whether a cache entry exists or not with Dalli.
-
Args :
-
key
-> The key of the cache entry
-
-
Returns :
-
True/False determining whether the key exists in the cache or not
-
82 83 84 |
# File 'lib/AboutYou/CacheProvider/dalli.rb', line 82 def exists(key) !client.get(key).nil? end |
#get(key) ⇒ Object
This method is used for getting cache entries with Dalli.
-
Args :
-
key
-> The key of the cache entry
-
-
Returns :
-
Either the value for the given key or nil if the key was not found
-
56 57 58 |
# File 'lib/AboutYou/CacheProvider/dalli.rb', line 56 def get(key) client.get(key) end |
#set(key, value, duration) ⇒ Object
This method is used for setting new cache entries with Dalli.
-
Args :
-
key
-> The key of the cache entry -
value
-> The value of the cache entry -
duration
-> the duration of the cache entry
-
-
Returns :
-
True/False determining whether the setting was successful of not
-
43 44 45 |
# File 'lib/AboutYou/CacheProvider/dalli.rb', line 43 def set(key, value, duration) client.set(key, value, duration) end |