Skip to content

Instantly share code, notes, and snippets.

View CiTroNaK's full-sized avatar

Petr Hlavicka CiTroNaK

View GitHub Profile
@CiTroNaK
CiTroNaK / clear_redis_script.rb
Last active July 19, 2019 13:57 — forked from brasic/clear_redis_script.rb
Clear a large number of redis keys by pattern using SCAN and pipelining
#!/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