This file contains hidden or 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
// The following test runs against a local Consul server started like so: | |
// | |
// consul agent -server -bootstrap-expect 1 -data-dir /tmp/consul | |
// | |
// The test output looks like this: | |
// | |
// % go test -test.v | |
// === RUN TestConsul | |
// --- PASS: TestConsul (6.76s) | |
// consul_test.go:188: LastIndex after #1: 5 |
This file contains hidden or 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
$redis = Redis.new | |
class SafeHashDelete | |
@queue = :garbage_collection | |
BATCH_SIZE = 100 | |
# Rename the key and queue for deletion | |
def self.delete(key) | |
newkey = "gc:hashes:#{$redis.incr("gc:index")}" |
This file contains hidden or 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
$redis = Redis.new | |
class SafeHashDelete | |
include Sidekiq::Worker | |
BATCH_SIZE = 100 | |
# Rename the key and queue for deletion | |
def self.delete(key) | |
newkey = "gc:hashes:#{$redis.incr("gc:index")}" |
This file contains hidden or 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
$redis = Redis.new | |
class SafeListDelete | |
@queue = :garbage_collection | |
BATCH_SIZE = 100 | |
# Rename the key and queue for deletion | |
def self.delete(key) | |
newkey = "gc:lists:#{$redis.incr("gc:index")}" |
This file contains hidden or 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
$redis = Redis.new | |
class SafeListDelete | |
include Sidekiq::Worker | |
BATCH_SIZE = 100 | |
# Rename the key and queue for deletion | |
def self.delete(key) | |
newkey = "gc:lists:#{$redis.incr("gc:index")}" |
This file contains hidden or 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
$redis = Redis.new | |
class SafeSetDelete | |
@queue = :garbage_collection | |
BATCH_SIZE = 100 | |
# Rename the key and queue for deletion | |
def self.delete(key) | |
newkey = "gc:sets:#{$redis.incr("gc:index")}" |
This file contains hidden or 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
$redis = Redis.new | |
class SafeSetDelete | |
include Sidekiq::Worker | |
BATCH_SIZE = 100 | |
# Rename the key and queue for deletion | |
def self.delete(key) | |
newkey = "gc:sets:#{$redis.incr("gc:index")}" |
This file contains hidden or 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
$redis = Redis.new | |
class SafeSortedSetDelete | |
include Sidekiq::Worker | |
BATCH_SIZE = 100 | |
# Rename the key and queue for deletion | |
def self.delete(key) | |
newkey = "gc:zsets:#{$redis.incr("gc:index")}" |
This file contains hidden or 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
$redis = Redis.new | |
class SafeSortedSetDelete | |
@queue = :garbage_collection | |
BATCH_SIZE = 100 | |
# Rename the key and queue for deletion | |
def self.delete(key) | |
newkey = "gc:zsets:#{$redis.incr("gc:index")}" |
This file contains hidden or 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
require 'redis' | |
REDIS = Redis.new( url: "..." ) | |
def each_keys_chunk( pattern = nil, &block ) | |
opts = { count: 100 } | |
opts[:match] = pattern if pattern | |
cursor = 0 | |
loop do | |
cursor, keys = REDIS.scan( cursor, opts ) |