Skip to content
Extraits de code Groupes Projets
Valider b53df6dd rédigé par danielgrippi's avatar danielgrippi
Parcourir les fichiers

repopulating the redis cache should clear the entire set first

parent fd76cfd4
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -39,9 +39,14 @@ class RedisCache
end
def repopulate!(opts = {})
self.purge!
self.populate!(opts) && self.trim!
end
def purge!
self.redis.del(set_key)
end
def populate!(opts = {})
# user executes query and gets back hashes
opts.merge!({
......
......@@ -63,7 +63,7 @@ describe RedisCache do
@cache.ensure_populated!
end
it 'clears and poplulates if the cache is not populated' do
it 'calls #repopulate' do
opts = {:here_is => "something"}
@cache.stub(:cache_exists?).and_return(false)
@cache.should_receive(:repopulate!).with(opts)
......@@ -73,6 +73,11 @@ describe RedisCache do
end
describe "#repopulate!" do
it 'calls #purge!' do
@cache.should_receive(:purge!)
@cache.repopulate!
end
it 'populates' do
opts = {:here_is => "something"}
@cache.stub(:trim!).and_return(true)
......@@ -87,6 +92,14 @@ describe RedisCache do
end
end
describe '#purge!' do
it 'clears the set in redis' do
@cache.stub(:redis).and_return(@redis)
@redis.should_receive(:del).with(@cache.send(:set_key))
@cache.purge!
end
end
describe "#populate!" do
it 'queries the db with the visible post sql string' do
sql = "long_sql"
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter