-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add rake task to remove Redis namespacing
In Sidekiq 7, `redis_namespace` is no longer supported. We therefore need to run a migration at the point of upgrading to remove the namespace from existing Redis keys. If we don't run the migration, already queued jobs won't get processed.
- Loading branch information
Showing
3 changed files
with
21 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
namespace :redis_namespace do | ||
desc "Remove application specific namespacing for all Redis keys" | ||
task :remove_namespace, :environment do | ||
namespace = ENV["GOVUK_APP_NAME"] | ||
|
||
redis = RedisClient.new(url: ENV["REDIS_URL"]) | ||
|
||
namespaced_keys = redis.call("KEYS", "#{namespace}:*") | ||
|
||
namespaced_keys.each do |key| | ||
new_key = key.gsub(/^#{namespace}:/, "") | ||
redis.call("RENAME", key, new_key) | ||
end | ||
end | ||
end |