diff --git a/lib/tasks/redis.rake b/lib/tasks/redis.rake new file mode 100644 index 00000000000..fd9871dba3d --- /dev/null +++ b/lib/tasks/redis.rake @@ -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