Module: Venduitz::Cache
- Defined in:
- lib/venduitz/cache.rb
Overview
Module responsible for creating an interface for the different cache storages
Class Attribute Summary collapse
-
.config ⇒ Object
Config.
-
.digestor ⇒ Object
Returns the value of attribute digestor.
-
.driver ⇒ Object
Returns the value of attribute driver.
-
.enabled ⇒ Object
Returns the value of attribute enabled.
-
.namespace ⇒ Object
Get the namespace.
Class Method Summary collapse
-
.clear(opts = nil) ⇒ Object
Clear the full cache.
-
.digest(object) ⇒ Object
Digest.
-
.exist?(key) ⇒ Boolean
Check if the key exists.
-
.get(key) ⇒ Object
Get the key.
-
.namespace? ⇒ Boolean
Check if there is namespace.
-
.set(key, value, dump = true, options = {}) ⇒ Object
Set the cache.
Class Attribute Details
.config ⇒ Object
Config
74 75 76 |
# File 'lib/venduitz/cache.rb', line 74 def config @config end |
.digestor ⇒ Object
Returns the value of attribute digestor.
9 10 11 |
# File 'lib/venduitz/cache.rb', line 9 def digestor @digestor end |
.driver ⇒ Object
Returns the value of attribute driver.
9 10 11 |
# File 'lib/venduitz/cache.rb', line 9 def driver @driver end |
.enabled ⇒ Object
Returns the value of attribute enabled.
9 10 11 |
# File 'lib/venduitz/cache.rb', line 9 def enabled @enabled end |
.namespace ⇒ Object
Get the namespace
69 70 71 |
# File 'lib/venduitz/cache.rb', line 69 def namespace @namespace end |
Class Method Details
.clear(opts = nil) ⇒ Object
Clear the full cache
59 60 61 |
# File 'lib/venduitz/cache.rb', line 59 def clear(opts = nil) _driver.clear(opts) end |
.digest(object) ⇒ Object
Digest
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/venduitz/cache.rb', line 20 def digest(object) # The dumped data dump = Marshal::dump(object) # Check if the digestor is empty digestor = Digest::MD5 if digestor.nil? # Digest it digestor.hexdigest dump end |
.exist?(key) ⇒ Boolean
Check if the key exists
32 33 34 |
# File 'lib/venduitz/cache.rb', line 32 def exist?(key) _driver.exist?(key) end |
.get(key) ⇒ Object
Get the key
37 38 39 40 |
# File 'lib/venduitz/cache.rb', line 37 def get(key) # Using the driver itself _driver.get(key) end |
.namespace? ⇒ Boolean
Check if there is namespace
64 65 66 |
# File 'lib/venduitz/cache.rb', line 64 def namespace? !@namespace.nil? end |
.set(key, value, dump = true, options = {}) ⇒ Object
Set the cache
46 47 48 49 50 51 52 53 54 55 |
# File 'lib/venduitz/cache.rb', line 46 def set(key, value, dump = true, = {}) # key = digest(key) if dump # If the driver has any namespace method or fixed value key = "#{namespace}/#{key}" if namespace? # _driver.set(key, value, ) end |