Class: CollectionSpace::RefCache::Backend::Redis
- Inherits:
-
Object
- Object
- CollectionSpace::RefCache::Backend::Redis
- Defined in:
- lib/collectionspace/refcache/backend/redis.rb
Instance Method Summary collapse
- #clean ⇒ Object
- #connected? ⇒ Boolean
- #exists?(key) ⇒ Boolean
- #flush ⇒ Object
- #get(key) ⇒ Object
-
#initialize(url) ⇒ Redis
constructor
A new instance of Redis.
- #put(key, value, lifetime: nil) ⇒ Object
- #remove(key) ⇒ Object
- #size ⇒ Object
Constructor Details
#initialize(url) ⇒ Redis
Returns a new instance of Redis.
9 10 11 12 |
# File 'lib/collectionspace/refcache/backend/redis.rb', line 9 def initialize(url) # https://devcenter.heroku.com/articles/heroku-redis#connecting-in-rails @c = ::Redis.new(url: url, ssl_params: {verify_mode: OpenSSL::SSL::VERIFY_NONE}) end |
Instance Method Details
#clean ⇒ Object
14 15 16 17 |
# File 'lib/collectionspace/refcache/backend/redis.rb', line 14 def clean # blank method; Redis handles removal of expired keys automagically, as per # https://redis.io/commands/expire end |
#connected? ⇒ Boolean
19 20 21 22 23 |
# File 'lib/collectionspace/refcache/backend/redis.rb', line 19 def connected? @c.ping rescue false end |
#exists?(key) ⇒ Boolean
25 26 27 |
# File 'lib/collectionspace/refcache/backend/redis.rb', line 25 def exists?(key) @c.exists?(key) end |
#flush ⇒ Object
29 30 31 |
# File 'lib/collectionspace/refcache/backend/redis.rb', line 29 def flush @c.flushdb end |
#get(key) ⇒ Object
33 34 35 |
# File 'lib/collectionspace/refcache/backend/redis.rb', line 33 def get(key) @c.get(key) end |
#put(key, value, lifetime: nil) ⇒ Object
37 38 39 |
# File 'lib/collectionspace/refcache/backend/redis.rb', line 37 def put(key, value, lifetime: nil) @c.set(key, value, ex: lifetime) end |
#remove(key) ⇒ Object
41 42 43 |
# File 'lib/collectionspace/refcache/backend/redis.rb', line 41 def remove(key) @c.del(key) end |
#size ⇒ Object
45 46 47 |
# File 'lib/collectionspace/refcache/backend/redis.rb', line 45 def size @c.dbsize end |