Permalink
Browse files

Merge pull request #147 from gregorym/master

Override flushdb for namespaced datastore
  • Loading branch information...
2 parents f74e47f + d7bbd8e commit a58f86d76f6645a53acbb5a218606080f2624574 @jodosha jodosha committed Sep 3, 2012
Showing with 16 additions and 1 deletion.
  1. +4 −0 redis-store/lib/redis/store/namespace.rb
  2. +12 −1 redis-store/test/redis/store/namespace_test.rb
@@ -41,6 +41,10 @@ def to_s
"#{super} with namespace #{@namespace}"
end
+ def flushdb
+ del *keys
+ end
+
private
def namespace(key)
yield interpolate(key)
@@ -23,6 +23,17 @@ def teardown
@store.send(:interpolate, "#{@namespace}:rabbit").must_equal("#{@namespace}:rabbit")
end
+ it "should ony delete namespaced keys" do
+ other_store = Redis::Store.new
+
+ other_store.set 'abc', 'cba'
+ @store.set 'def', 'fed'
+
+ @store.flushdb
+ @store.get('def').must_equal(nil)
+ other_store.get('abc').must_equal('cba')
+ end
+
it "namespaces get"
it "namespaces set"
it "namespaces setnx"
@@ -33,7 +44,7 @@ def teardown
it "namespaces incrby"
it "namespaces decrby"
it "namespaces mget"
-
+
# it "should namespace get" do
# @client.expects(:call).with([:get, "#{@namespace}:rabbit"]).once
# @store.get("rabbit")

0 comments on commit a58f86d

Please sign in to comment.