Class: Jiggler::RedisStore

Inherits:
Object
  • Object
show all
Defined in:
lib/jiggler/redis_store.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ RedisStore

Returns a new instance of RedisStore.



7
8
9
# File 'lib/jiggler/redis_store.rb', line 7

def initialize(options = {})
  @options = options
end

Instance Method Details

#async_poolObject



15
16
17
18
19
20
21
22
# File 'lib/jiggler/redis_store.rb', line 15

def async_pool
  @async_pool ||= begin
    config = RedisClient.config(url: @options[:redis_url], timeout: nil)
    Async::Pool::Controller.wrap(limit: @options[:concurrency]) do
      config.new_client
    end
  end
end

#poolObject



11
12
13
# File 'lib/jiggler/redis_store.rb', line 11

def pool      
  @options[:async] ? async_pool : sync_pool
end

#sync_poolObject



24
25
26
27
28
29
30
31
32
33
# File 'lib/jiggler/redis_store.rb', line 24

def sync_pool
  @sync_pool ||= begin
    config = RedisClient.config(url: @options[:redis_url])
    pool = config.new_pool(size: @options[:concurrency])
    def pool.acquire(&block)
      with(&block)
    end
    pool
  end
end