Class: Kredis::Types::Scalar
Instance Attribute Summary collapse
Attributes inherited from Proxying
#key, #proxy, #redis
Instance Method Summary
collapse
Methods inherited from Proxying
#failsafe, #initialize, proxying
Instance Attribute Details
#default ⇒ Object
Returns the value of attribute default.
4
5
6
|
# File 'lib/kredis/types/scalar.rb', line 4
def default
@default
end
|
#expires_in ⇒ Object
Returns the value of attribute expires_in.
4
5
6
|
# File 'lib/kredis/types/scalar.rb', line 4
def expires_in
@expires_in
end
|
#typed ⇒ Object
Returns the value of attribute typed.
4
5
6
|
# File 'lib/kredis/types/scalar.rb', line 4
def typed
@typed
end
|
Instance Method Details
#assigned? ⇒ Boolean
24
25
26
|
# File 'lib/kredis/types/scalar.rb', line 24
def assigned?
exists?
end
|
#clear ⇒ Object
28
29
30
|
# File 'lib/kredis/types/scalar.rb', line 28
def clear
del
end
|
#expire_at(datetime) ⇒ Object
36
37
38
|
# File 'lib/kredis/types/scalar.rb', line 36
def expire_at(datetime)
expireat datetime.to_i
end
|
#expire_in(seconds) ⇒ Object
32
33
34
|
# File 'lib/kredis/types/scalar.rb', line 32
def expire_in(seconds)
expire seconds.to_i
end
|
#to_s ⇒ Object
20
21
22
|
# File 'lib/kredis/types/scalar.rb', line 20
def to_s
get || default&.to_s
end
|
#value ⇒ Object
10
11
12
13
14
15
16
17
18
|
# File 'lib/kredis/types/scalar.rb', line 10
def value
value_after_casting = string_to_type(get, typed)
if value_after_casting.nil?
default
else
value_after_casting
end
end
|
#value=(value) ⇒ Object
6
7
8
|
# File 'lib/kredis/types/scalar.rb', line 6
def value=(value)
set type_to_string(value, typed), ex: expires_in
end
|