Class: Cistern::Data::Redis
- Inherits:
-
Object
- Object
- Cistern::Data::Redis
- Defined in:
- lib/cistern/data/redis.rb
Class Method 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.
18 19 20 21 |
# File 'lib/cistern/data/redis.rb', line 18 def initialize(={}, &block) @client = [:client] || ::Redis.new @default = block end |
Class Method Details
.marshal ⇒ Object
4 5 6 7 8 9 10 11 12 |
# File 'lib/cistern/data/redis.rb', line 4 def self.marshal @marshal ||= begin require 'multi_json' MultiJson rescue LoadError require 'json' ::JSON end end |
.marshal=(marshal) ⇒ Object
14 15 16 |
# File 'lib/cistern/data/redis.rb', line 14 def self.marshal=(marshal) @marshal = marshal end |
Instance Method Details
#clear ⇒ Object
23 24 25 26 27 |
# File 'lib/cistern/data/redis.rb', line 23 def clear unless (keys = client.keys("*")).empty? client.del(*keys) end end |