Support delete method for Redis

This commit is contained in:
Stan Hu 2015-03-15 11:57:12 -07:00
parent efdef7f45c
commit ff15447f3a
2 changed files with 13 additions and 0 deletions

View file

@ -36,6 +36,10 @@ module Rack
rescue Redis::BaseError
end
def delete(key, options={})
self.del(key)
rescue Redis::BaseError
end
end
end
end

View file

@ -80,6 +80,15 @@ describe Rack::Attack::Cache do
@cache.read("cache-test-key").must_equal "foobar"
end
end
describe "delete" do
it "must delete the value" do
store.write(@key, "foobar", :expires_in => @expires_in)
@cache.read('cache-test-key').must_equal "foobar"
store.delete(@key)
@cache.read('cache-test-key').must_equal nil
end
end
end
end