Skip to content

Commit

Permalink
feature: add support for redis >= v4
Browse files Browse the repository at this point in the history
  • Loading branch information
isqad committed Dec 26, 2018
1 parent edce26d commit 2f4ceab
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions lib/redis_counters/dumpers/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -234,10 +234,16 @@ def delete_from_redis
end

def redis_session
@redis_session ||= begin
redis = ::Redis.new(counter.redis.client.options)
::Redis::Namespace.new(counter.redis.namespace, :redis => redis)
end
return @redis_session if defined?(@redis_session)

client = if Gem::Version.new(::Redis::VERSION) < Gem::Version.new('4')
counter.redis.client
else
counter.redis._client
end
redis = ::Redis.new(client.options)

@redis_session = ::Redis::Namespace.new(counter.redis.namespace, redis: redis)
end

def create_temp_table
Expand Down

0 comments on commit 2f4ceab

Please sign in to comment.