lib/cache/merb/redis_store.rb in redis-store-1.0.0.beta2 vs lib/cache/merb/redis_store.rb in redis-store-1.0.0.beta3

- old
+ new

@@ -2,29 +2,41 @@ module Cache class RedisStore < AbstractStore # Instantiate the store. # # Example: - # RedisStore.new # => host: localhost, port: 6379, db: 0 - # RedisStore.new :servers => ["example.com"] # => host: example.com, port: 6379, db: 0 - # RedisStore.new :servers => ["example.com:23682"] # => host: example.com, port: 23682, db: 0 - # RedisStore.new :servers => ["example.com:23682/1"] # => host: example.com, port: 23682, db: 1 - # RedisStore.new :servers => ["localhost:6379/0", "localhost:6380/0"] # => instantiate a cluster - def initialize(config = {}) + # RedisStore.new + # # => host: localhost, port: 6379, db: 0 + # + # RedisStore.new :servers => ["example.com"] + # # => host: example.com, port: 6379, db: 0 + # + # RedisStore.new :servers => ["example.com:23682"] + # # => host: example.com, port: 23682, db: 0 + # + # RedisStore.new :servers => ["example.com:23682/1"] + # # => host: example.com, port: 23682, db: 1 + # + # RedisStore.new :servers => ["example.com:23682/1/theplaylist"] + # # => host: example.com, port: 23682, db: 1, namespace: theplaylist + # + # RedisStore.new :servers => ["localhost:6379/0", "localhost:6380/0"] + # # => instantiate a cluster + def initialize(config = { }) @data = Redis::Factory.create config[:servers] end def writable?(key, parameters = {}, conditions = {}) true end def read(key, parameters = {}, conditions = {}) - @data.marshalled_get normalize(key, parameters), conditions + @data.get normalize(key, parameters), conditions end def write(key, data = nil, parameters = {}, conditions = {}) if writable?(key, parameters, conditions) - method = conditions && conditions[:unless_exist] ? :marshalled_setnx : :marshalled_set + method = conditions && conditions[:unless_exist] ? :setnx : :set @data.send method, normalize(key, parameters), data, conditions end end def write_all(key, data = nil, parameters = {}, conditions = {})