Sha256: aec3281bdfe252b4e693b6fbd9c3ca93b151170174353c3a474aac4d17d8666e

Contents?: true

Size: 677 Bytes

Versions: 2

Compression:

Stored size: 677 Bytes

Contents

# frozen_string_literal: true

require_relative "base"

module SidekiqAlive
  module Redis
    # Wrapper for `redis` gem used by sidekiq < 7
    # https://github.com/redis/redis-rb
    class RedisGem < Base
      def set(key, time:, ex:)
        redis.set(key, time, ex: ex)
      end

      def get(key)
        redis.get(key)
      end

      def match(key)
        keys = []
        cursor = 0

        loop do
          cursor, found_keys = redis.scan(cursor, match: key, count: 1000)
          keys += found_keys if found_keys
          break if cursor.to_i == 0
        end
        keys
      end

      def delete(key)
        redis.del(key)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sidekiq_alive-2.2.1 lib/sidekiq_alive/redis/redis_gem.rb
sidekiq_alive-2.2.0 lib/sidekiq_alive/redis/redis_gem.rb