Class: CollectionSpace::RefCache::Backend::Zache

Inherits:
Object
  • Object
show all
Defined in:
lib/collectionspace/refcache/backend/zache.rb

Instance Method Summary collapse

Constructor Details

#initializeZache

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

#cleanObject



13
14
15
# File 'lib/collectionspace/refcache/backend/zache.rb', line 13

def clean
  @c.remove_by { |key| @c.expired?(key) }
end

#connected?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/collectionspace/refcache/backend/zache.rb', line 17

def connected?
  "PONG" # cute, matches redis response
end

#exists?(key) ⇒ Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/collectionspace/refcache/backend/zache.rb', line 21

def exists?(key)
  @c.exists?(key)
end

#flushObject



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

#sizeObject



43
44
45
# File 'lib/collectionspace/refcache/backend/zache.rb', line 43

def size
  @c.size
end