Class: Kredis::Types::Counter
Instance Attribute Summary collapse
Attributes inherited from Proxying
#key, #proxy
Instance Method Summary
collapse
#initialize
Methods inherited from Proxying
#failsafe, #initialize, proxying, #unproxied_redis
Instance Attribute Details
#expires_in ⇒ Object
Returns the value of attribute expires_in.
8
9
10
|
# File 'lib/kredis/types/counter.rb', line 8
def expires_in
@expires_in
end
|
Instance Method Details
#decrement(by: 1) ⇒ Object
17
18
19
20
21
22
|
# File 'lib/kredis/types/counter.rb', line 17
def decrement(by: 1)
multi do
set 0, ex: expires_in, nx: true if expires_in
decrby by
end[-1]
end
|
#increment(by: 1) ⇒ Object
10
11
12
13
14
15
|
# File 'lib/kredis/types/counter.rb', line 10
def increment(by: 1)
multi do
set 0, ex: expires_in, nx: true if expires_in
incrby by
end[-1]
end
|
#reset ⇒ Object
28
29
30
|
# File 'lib/kredis/types/counter.rb', line 28
def reset
del
end
|
#value ⇒ Object
24
25
26
|
# File 'lib/kredis/types/counter.rb', line 24
def value
get.to_i
end
|