Skip to content

Commit

Permalink
flush specific redis namespaces via rake (#421)
Browse files Browse the repository at this point in the history
* flush specific redis namespaces via rake

* minor fix

* allow rake task to invoke environment for models
  • Loading branch information
saneshark authored and aub committed Nov 3, 2016
1 parent bfe2b84 commit e4975d5
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions lib/tasks/redis.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# frozen_string_literal: true
namespace :redis do
desc 'Flush Vets.gov User/Sessions'
task flush_session: [:flush_session_store, :flush_users_store]

desc 'Flush RedisStore: Session'
task flush_session_store: :environment do
namespace = Session.new.redis_namespace.namespace
redis = Redis.current
redis.scan_each(match: "#{namespace}:*") do |key|
redis.del(key)
end
end

desc 'Flush RedisStore: User'
task flush_users_store: :environment do
namespace = User.new.redis_namespace.namespace
redis = Redis.current
redis.scan_each(match: "#{namespace}:*") do |key|
redis.del(key)
end
end
end

0 comments on commit e4975d5

Please sign in to comment.