class Kredis::Types::Scalar

Attributes

default[RW]
expires_in[RW]
typed[RW]

Public Instance Methods

assigned?() click to toggle source
# File lib/kredis/types/scalar.rb, line 24
def assigned?
  exists?
end
clear() click to toggle source
# File lib/kredis/types/scalar.rb, line 28
def clear
  del
end
expire_at(datetime) click to toggle source
# File lib/kredis/types/scalar.rb, line 36
def expire_at(datetime)
  expireat datetime.to_i
end
expire_in(seconds) click to toggle source
# File lib/kredis/types/scalar.rb, line 32
def expire_in(seconds)
  expire seconds.to_i
end
to_s() click to toggle source
# File lib/kredis/types/scalar.rb, line 20
def to_s
  get || default&.to_s
end
value() click to toggle source
# 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) click to toggle source
# File lib/kredis/types/scalar.rb, line 6
def value=(value)
  set type_to_string(value, typed), ex: expires_in
end