Skip to content

Instantly share code, notes, and snippets.

Petr Hlavicka CiTroNaK

View GitHub Profile
@CiTroNaK
CiTroNaK / clear_redis_script.rb
Last active Jul 19, 2019 — forked from brasic/clear_redis_script.rb
Clear a large number of redis keys by pattern using SCAN and pipelining
View clear_redis_script.rb
#!/usr/bin/env ruby
require 'redis'
# Clear a large number of keys matching a pattern using SCAN and
# pipelining to avoid killing the server.
class ClearKeys
def initialize(pattern, url, postprocess_pattern=nil)
@redis = Redis.new(url: url)
@pattern = pattern
You can’t perform that action at this time.