Class: Picky::Backends::Redis::String
- Defined in:
- lib/picky/backends/redis/string.rb
Instance Attribute Summary
Attributes inherited from Basic
Instance Method Summary collapse
-
#[](key) ⇒ Object
Get a single value.
-
#[]=(key, value) ⇒ Object
Set a single value.
-
#clear ⇒ Object
Clears the hash.
-
#delete(key) ⇒ Object
Deletes the single value.
-
#dump(hash) ⇒ Object
Writes the hash into Redis.
-
#size ⇒ Object
Returns the size of the hash.
Methods inherited from Basic
#empty, #initial, #initialize, #load, #reset, #retrieve, #to_s
Constructor Details
This class inherits a constructor from Picky::Backends::Redis::Basic
Instance Method Details
#[](key) ⇒ Object
Get a single value.
Internal API method for the index.
44 45 46 |
# File 'lib/picky/backends/redis/string.rb', line 44 def [] key client.hget namespace, key end |
#[]=(key, value) ⇒ Object
Set a single value
50 51 52 |
# File 'lib/picky/backends/redis/string.rb', line 50 def []= key, value client.hset namespace, key, value end |
#clear ⇒ Object
Clears the hash.
11 12 13 |
# File 'lib/picky/backends/redis/string.rb', line 11 def clear client.del namespace end |
#delete(key) ⇒ Object
Deletes the single value.
23 24 25 |
# File 'lib/picky/backends/redis/string.rb', line 23 def delete key client.hdel namespace, key end |
#dump(hash) ⇒ Object
Writes the hash into Redis.
Note: We could use multi, but it did not help.
31 32 33 34 35 36 37 38 |
# File 'lib/picky/backends/redis/string.rb', line 31 def dump hash unless @realtime clear hash.each_pair do |key, value| client.hset namespace, key, value end end end |
#size ⇒ Object
Returns the size of the hash.
17 18 19 |
# File 'lib/picky/backends/redis/string.rb', line 17 def size client.hlen namespace end |