Class: CollectionSpace::RefCache::Backend::Zache
- Inherits:
-
Object
- Object
- CollectionSpace::RefCache::Backend::Zache
- Defined in:
- lib/collectionspace/refcache/backend/zache.rb
Instance Method Summary collapse
- #clean ⇒ Object
- #connected? ⇒ Boolean
- #exists?(key) ⇒ Boolean
- #flush ⇒ Object
- #get(key) ⇒ Object
-
#initialize ⇒ Zache
constructor
A new instance of Zache.
- #put(key, value, lifetime: nil) ⇒ Object
- #remove(key) ⇒ Object
- #size ⇒ Object
Constructor Details
#initialize ⇒ Zache
Returns a new instance of Zache.
9 10 11 |
# File 'lib/collectionspace/refcache/backend/zache.rb', line 9 def initialize @c = ::Zache.new end |
Instance Method Details
#clean ⇒ Object
13 14 15 |
# File 'lib/collectionspace/refcache/backend/zache.rb', line 13 def clean @c.remove_by { |key| @c.expired?(key) } end |
#connected? ⇒ Boolean
17 18 19 |
# File 'lib/collectionspace/refcache/backend/zache.rb', line 17 def connected? "PONG" # cute, matches redis response end |
#exists?(key) ⇒ Boolean
21 22 23 |
# File 'lib/collectionspace/refcache/backend/zache.rb', line 21 def exists?(key) @c.exists?(key) end |
#flush ⇒ Object
25 26 27 |
# File 'lib/collectionspace/refcache/backend/zache.rb', line 25 def flush @c.remove_all end |
#get(key) ⇒ Object
29 30 31 32 33 |
# File 'lib/collectionspace/refcache/backend/zache.rb', line 29 def get(key) @c.get(key) rescue nil end |
#put(key, value, lifetime: nil) ⇒ Object
35 36 37 |
# File 'lib/collectionspace/refcache/backend/zache.rb', line 35 def put(key, value, lifetime: nil) @c.put(key, value, lifetime: lifetime) end |
#remove(key) ⇒ Object
39 40 41 |
# File 'lib/collectionspace/refcache/backend/zache.rb', line 39 def remove(key) @c.remove(key) end |
#size ⇒ Object
43 44 45 |
# File 'lib/collectionspace/refcache/backend/zache.rb', line 43 def size @c.size end |