Class: Kestrel::Client::Blocking
- Inherits:
-
Proxy
- Object
- Proxy
- Kestrel::Client::Blocking
show all
- Defined in:
- lib/kestrel/client/blocking.rb
Constant Summary
collapse
- DEFAULT_EXPIRY =
0
- WAIT_TIME_BEFORE_RETRY =
0.25
Instance Attribute Summary
Attributes inherited from Proxy
#client
Instance Method Summary
collapse
Methods inherited from Proxy
#initialize, #method_missing
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class Kestrel::Client::Proxy
Instance Method Details
#get(*args) ⇒ Object
7
8
9
10
11
12
|
# File 'lib/kestrel/client/blocking.rb', line 7
def get(*args)
while !(response = client.get(*args))
sleep WAIT_TIME_BEFORE_RETRY
end
response
end
|
#get_without_blocking(*args) ⇒ Object
14
15
16
|
# File 'lib/kestrel/client/blocking.rb', line 14
def get_without_blocking(*args)
client.get(*args)
end
|
#set(key, value, expiry = DEFAULT_EXPIRY, raw = false) ⇒ Object
18
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/kestrel/client/blocking.rb', line 18
def set(key, value, expiry = DEFAULT_EXPIRY, raw = false)
@retried = false
begin
client.set(key, value, expiry, raw)
rescue Memcached::Error => e
raise if @retried
sleep(WAIT_TIME_BEFORE_RETRY)
@retried = true
retry
end
end
|