Patch `rake cache:clear` for large amounts of keys

This commit is contained in:
Jacob Vosmaer 2014-06-20 13:58:57 +02:00
parent 995d193d32
commit cf0a370274
1 changed files with 6 additions and 1 deletions

View File

@ -1,6 +1,11 @@
namespace :cache do
desc "GITLAB | Clear redis cache"
task :clear => :environment do
Rails.cache.clear
# Hack into Rails.cache until https://github.com/redis-store/redis-store/pull/225
# is accepted (I hope) and we can update the redis-store gem.
redis_store = Rails.cache.instance_variable_get(:@data)
redis_store.keys.each_slice(1000) do |key_slice|
redis_store.del(*key_slice)
end
end
end