Skip to content

Commit

Permalink
feature: support for redis >= v4
Browse files Browse the repository at this point in the history
  • Loading branch information
isqad committed Dec 21, 2018
1 parent a7f77ed commit 49a3422
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
1 change: 0 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,3 @@ source 'https://rubygems.org'
gemspec

gem 'pg', '< 1.0.0'
gem 'redis', '< 4.0.0'
7 changes: 5 additions & 2 deletions lib/treasury/bg_executor/client.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# coding: utf-8
require 'digest/sha2'

module Treasury
Expand Down Expand Up @@ -28,7 +27,11 @@ def redis
end

def reconnect!
redis.redis.client.reconnect
if Gem::Version.new(::Redis::VERSION) < Gem::Version.new('4')
redis.redis.client.reconnect
else
redis.redis._client.reconnect
end
end

# поставить задачу в очередь
Expand Down
8 changes: 7 additions & 1 deletion lib/treasury/storage/redis/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,13 @@ def internal_write(object, data)
end

def self.new_redis_session
::Redis.new(Treasury.configuration.redis.client.options)
client = if Gem::Version.new(::Redis::VERSION) < Gem::Version.new('4')
Treasury.configuration.redis.client
else
Treasury.configuration.redis._client
end

::Redis.new(client.options)
end

module Batch
Expand Down

0 comments on commit 49a3422

Please sign in to comment.