Class: Picky::Backends::Redis::Basic
- Defined in:
- lib/picky/backends/redis/basic.rb
Overview
Redis Backend Accessor.
Provides necessary helper methods for its subclasses. Not directly useable, as it does not provide dump/load methods.
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#namespace ⇒ Object
readonly
Returns the value of attribute namespace.
Instance Method Summary collapse
-
#empty ⇒ Object
The empty index that is used for putting the index together.
-
#initial ⇒ Object
The initial content before loading.
-
#initialize(client, namespace, options = {}) ⇒ Basic
constructor
An index cache takes a path, without file extension, which will be provided by the subclasses.
-
#load(_) ⇒ Object
Returns itself.
-
#reset ⇒ Object
Clears the whole namespace.
-
#retrieve ⇒ Object
We do not use Redis to retrieve data.
- #to_s ⇒ Object
Constructor Details
#initialize(client, namespace, options = {}) ⇒ Basic
An index cache takes a path, without file extension, which will be provided by the subclasses.
21 22 23 24 25 26 27 28 |
# File 'lib/picky/backends/redis/basic.rb', line 21 def initialize client, namespace, = {} @client = client @namespace = namespace @empty = [:empty] @initial = [:initial] @realtime = [:realtime] end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
16 17 18 |
# File 'lib/picky/backends/redis/basic.rb', line 16 def client @client end |
#namespace ⇒ Object (readonly)
Returns the value of attribute namespace.
16 17 18 |
# File 'lib/picky/backends/redis/basic.rb', line 16 def namespace @namespace end |
Instance Method Details
#empty ⇒ Object
The empty index that is used for putting the index together.
33 34 35 |
# File 'lib/picky/backends/redis/basic.rb', line 33 def empty @empty && @empty.clone || (@realtime ? self.reset : {}) end |
#initial ⇒ Object
The initial content before loading.
Note: As Redis indexes needn’t be loaded per se,
this just returns the same thing as #load.
42 43 44 |
# File 'lib/picky/backends/redis/basic.rb', line 42 def initial @initial && @initial.clone || (@realtime ? self.reset : {}) end |
#load(_) ⇒ Object
Returns itself.
48 49 50 |
# File 'lib/picky/backends/redis/basic.rb', line 48 def load _ self end |
#reset ⇒ Object
Clears the whole namespace.
60 61 62 63 |
# File 'lib/picky/backends/redis/basic.rb', line 60 def reset clear self end |
#retrieve ⇒ Object
We do not use Redis to retrieve data.
54 55 56 |
# File 'lib/picky/backends/redis/basic.rb', line 54 def retrieve # Nothing. end |
#to_s ⇒ Object
67 68 69 |
# File 'lib/picky/backends/redis/basic.rb', line 67 def to_s "#{self.class}(#{namespace}:*)" end |