Module: Sidekiq::RedisClientAdapter::CompatMethods

Defined in:
lib/sidekiq/redis_client_adapter.rb

Constant Summary collapse

USED_COMMANDS =

this is the set of Redis commands used by Sidekiq. Not guaranteed to be comprehensive, we use this as a performance enhancement to avoid calling method_missing on most commands

%w[bitfield bitfield_ro del exists expire flushdb
get hdel hget hgetall hincrby hlen hmget hset hsetnx incr incrby
lindex llen lmove lpop lpush lrange lrem mget mset ping pttl
publish rpop rpush sadd scard script set sismember smembers
srem ttl type unlink zadd zcard zincrby zrange zrem
zremrangebyrank zremrangebyscore]

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(*args, &block) ⇒ Object (private)

this allows us to use methods like ‘conn.hmset(…)` instead of having to use redis-client’s native ‘conn.call(“hmset”, …)`



44
45
46
47
# File 'lib/sidekiq/redis_client_adapter.rb', line 44

def method_missing(*args, &block)
  warn("[sidekiq#5788] Redis has deprecated the `#{args.first}`command, called at #{caller(1..1)}") if DEPRECATED_COMMANDS.include?(args.first)
  @client.call(*args, *block)
end

Instance Method Details

#evalsha(sha, keys, argv) ⇒ Object



20
21
22
# File 'lib/sidekiq/redis_client_adapter.rb', line 20

def evalsha(sha, keys, argv)
  @client.call("EVALSHA", sha, keys.size, *keys, *argv)
end

#infoObject



16
17
18
# File 'lib/sidekiq/redis_client_adapter.rb', line 16

def info
  @client.call("INFO") { |i| i.lines(chomp: true).map { |l| l.split(":", 2) }.select { |l| l.size == 2 }.to_h }
end