Class: TieredCaching::AsyncStore

Inherits:
Object
  • Object
show all
Defined in:
lib/tiered_caching/async_store.rb

Instance Method Summary collapse

Constructor Details

#initialize(store_pool, executor) ⇒ AsyncStore

Returns a new instance of AsyncStore.



4
5
6
7
# File 'lib/tiered_caching/async_store.rb', line 4

def initialize(store_pool, executor)
  @store_pool = store_pool
  @executor = executor
end

Instance Method Details

#clearObject



28
29
30
# File 'lib/tiered_caching/async_store.rb', line 28

def clear
  internal_store { |conn| conn.clear }
end

#delete(key) ⇒ Object



24
25
26
# File 'lib/tiered_caching/async_store.rb', line 24

def delete(key)
  internal_store { |conn| conn.delete(key) }
end

#get(key) ⇒ Object



16
17
18
# File 'lib/tiered_caching/async_store.rb', line 16

def get(key)
  internal_store { |conn| conn.get(key) }
end

#getset(key, &block) ⇒ Object



20
21
22
# File 'lib/tiered_caching/async_store.rb', line 20

def getset(key, &block)
  internal_store { |conn| conn.getset(key, &block) }
end

#set(key, value) ⇒ Object



9
10
11
12
13
14
# File 'lib/tiered_caching/async_store.rb', line 9

def set(key, value)
  Concurrent::Future.execute(executor: @executor) do
    internal_store { |conn| conn.set(key, value) }
  end
  value
end