Class: RubyPitaya::RedisService

Inherits:
ServiceBase show all
Defined in:
lib/rubypitaya/core/app/services/redis_service.rb

Instance Method Summary collapse

Methods inherited from ServiceBase

#clear_all_data

Constructor Details

#initialize(setup) ⇒ RedisService

Returns a new instance of RedisService.



8
9
10
11
# File 'lib/rubypitaya/core/app/services/redis_service.rb', line 8

def initialize(setup)
  @redis = nil
  @redis_address = setup['rubypitaya.redis.url']
end

Instance Method Details

#clientObject



26
27
28
# File 'lib/rubypitaya/core/app/services/redis_service.rb', line 26

def client
  @redis
end

#connectObject



13
14
15
16
17
18
19
20
# File 'lib/rubypitaya/core/app/services/redis_service.rb', line 13

def connect
  @redis = Redis.new(
    url: @redis_address,
    :reconnect_attempts => [1.5]*10,
  )

  @redis.ping
end

#disconnectObject



22
23
24
# File 'lib/rubypitaya/core/app/services/redis_service.rb', line 22

def disconnect
  @redis.close
end