Class: Cistern::Data::Redis
- Inherits:
-
Object
- Object
- Cistern::Data::Redis
- Defined in:
- lib/cistern/data/redis.rb
Class Attribute Summary collapse
Instance Method Summary collapse
- #clear ⇒ Object
- #fetch(key, *args) ⇒ Object (also: #[])
-
#initialize(options = {}, &block) ⇒ Redis
constructor
A new instance of Redis.
- #store(key, value, *args) ⇒ Object (also: #[]=)
Constructor Details
#initialize(options = {}, &block) ⇒ Redis
Returns a new instance of Redis.
20 21 22 23 |
# File 'lib/cistern/data/redis.rb', line 20 def initialize( = {}, &block) @client = [:client] || ::Redis.new @default = block end |
Class Attribute Details
.marshal ⇒ Object
6 7 8 9 10 11 12 13 14 |
# File 'lib/cistern/data/redis.rb', line 6 def self.marshal @marshal ||= begin require 'multi_json' MultiJson rescue LoadError require 'json' ::JSON end end |
Instance Method Details
#clear ⇒ Object
25 26 27 28 29 |
# File 'lib/cistern/data/redis.rb', line 25 def clear unless (keys = client.keys('*')).empty? client.del(*keys) end end |