Class: Sc4ry::Backends::Redis
- Inherits:
-
Object
- Object
- Sc4ry::Backends::Redis
- Defined in:
- lib/sc4ry/backends/redis.rb
Overview
Redis backend definition
Instance Method Summary collapse
-
#del(options) ⇒ Boolean
delete a specific record.
-
#exist?(options) ⇒ Boolean
verifiy a specific record existance.
-
#flush ⇒ Object
flush all records in backend.
-
#get(options) ⇒ String
return value of queried record.
-
#initialize(config) ⇒ Sc4ry::Backends::Redis
constructor
Constructor.
-
#list ⇒ Array
return the list of find records in backend for a specific pattern.
-
#put(options) ⇒ String
defined and store value for specified key.
Constructor Details
#initialize(config) ⇒ Sc4ry::Backends::Redis
Constructor
9 10 11 12 13 14 |
# File 'lib/sc4ry/backends/redis.rb', line 9 def initialize(config) @auth = config.slice(:auth)[:auth] @config = config.slice(:host, :port, :db) @be = ::Redis.new @config @be.auth(@auth) if @auth end |
Instance Method Details
#del(options) ⇒ Boolean
delete a specific record
44 45 46 |
# File 'lib/sc4ry/backends/redis.rb', line 44 def del() @store.del [:key] end |
#exist?(options) ⇒ Boolean
verifiy a specific record existance
57 58 59 |
# File 'lib/sc4ry/backends/redis.rb', line 57 def exist?() return ( not @store.get([:key]).nil?) end |
#flush ⇒ Object
flush all records in backend
49 50 51 |
# File 'lib/sc4ry/backends/redis.rb', line 49 def flush @store.flushdb end |
#get(options) ⇒ String
return value of queried record
27 28 29 |
# File 'lib/sc4ry/backends/redis.rb', line 27 def get() return @store.get([:key]) end |
#list ⇒ Array
return the list of find records in backend for a specific pattern
18 19 20 |
# File 'lib/sc4ry/backends/redis.rb', line 18 def list return @store.keys('*') end |
#put(options) ⇒ String
defined and store value for specified key
36 37 38 |
# File 'lib/sc4ry/backends/redis.rb', line 36 def put() @store.set [:key], [:value] end |