Class: Geode::RedisStore
Overview
A store implemented using Redis.
Instance Method Summary collapse
- #destroy ⇒ Object
-
#initialize(name, connection = nil) ⇒ RedisStore
constructor
Connect to a store held in Redis.
- #open ⇒ Object
Methods inherited from Store
Constructor Details
#initialize(name, connection = nil) ⇒ RedisStore
Connect to a store held in Redis.
12 13 14 15 16 |
# File 'lib/geode/redis.rb', line 12 def initialize(name, connection = nil) super connection ||= {} @redis = Redis.new(connection) end |
Instance Method Details
#destroy ⇒ Object
30 31 32 33 |
# File 'lib/geode/redis.rb', line 30 def destroy @redis.del @name nil end |
#open ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/geode/redis.rb', line 18 def open table = if @redis.exists? @name Marshal.load(@redis.get @name) else {} end (yield table).tap do @redis.set @name, Marshal.dump(table) end end |