2013-09-24 08:47:35 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
require 'cache'
|
|
|
|
|
|
|
|
describe "Redis Store" do
|
|
|
|
|
|
|
|
let :cache do
|
2014-01-06 00:50:04 -05:00
|
|
|
Cache.new(namespace: 'foo')
|
2013-09-24 08:47:35 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
let :store do
|
|
|
|
DiscourseRedis.new_redis_store
|
|
|
|
end
|
|
|
|
|
|
|
|
before(:each) do
|
|
|
|
cache.redis.del "key"
|
|
|
|
store.delete "key"
|
|
|
|
end
|
|
|
|
|
|
|
|
it "can store stuff" do
|
|
|
|
store.fetch "key" do
|
|
|
|
"key in store"
|
|
|
|
end
|
|
|
|
|
|
|
|
r = store.read "key"
|
|
|
|
|
|
|
|
r.should == "key in store"
|
|
|
|
end
|
|
|
|
|
|
|
|
it "doesn't collide with our Cache" do
|
2014-01-06 00:50:04 -05:00
|
|
|
|
2013-09-24 08:47:35 -04:00
|
|
|
store.fetch "key" do
|
|
|
|
"key in store"
|
|
|
|
end
|
2014-01-06 00:50:04 -05:00
|
|
|
|
2013-09-24 08:47:35 -04:00
|
|
|
cache.fetch "key" do
|
|
|
|
"key in cache"
|
|
|
|
end
|
2014-01-06 00:50:04 -05:00
|
|
|
|
2013-09-24 08:47:35 -04:00
|
|
|
r = store.read "key"
|
2014-01-06 00:50:04 -05:00
|
|
|
|
2013-09-24 08:47:35 -04:00
|
|
|
r.should == "key in store"
|
|
|
|
end
|
|
|
|
|
|
|
|
it "can be cleared without clearing our cache" do
|
|
|
|
store.fetch "key" do
|
|
|
|
"key in store"
|
|
|
|
end
|
|
|
|
|
|
|
|
cache.fetch "key" do
|
|
|
|
"key in cache"
|
|
|
|
end
|
|
|
|
|
|
|
|
store.clear
|
2014-09-25 11:44:48 -04:00
|
|
|
store.read("key").should == nil
|
2013-09-24 08:47:35 -04:00
|
|
|
cache.fetch("key").should == "key in cache"
|
2014-01-06 00:50:04 -05:00
|
|
|
|
2013-09-24 08:47:35 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|