Class: Redstruct::Types::Struct
- Includes:
- Utils::Inspectable
- Defined in:
- lib/redstruct/types/struct.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#delete ⇒ Fixnum
0 if nothing was deleted in the DB, 1 if it was.
-
#exists? ⇒ Boolean
Returns true if it exists in redis, false otherwise.
- #expire(ttl) ⇒ Object
- #expire_at(time) ⇒ Object
-
#inspectable_attributes ⇒ Object
:nocov:.
- #persist ⇒ Object
- #type ⇒ Object
Methods included from Utils::Inspectable
Methods inherited from Base
Constructor Details
This class inherits a constructor from Redstruct::Types::Base
Instance Method Details
#delete ⇒ Fixnum
Returns 0 if nothing was deleted in the DB, 1 if it was.
14 15 16 |
# File 'lib/redstruct/types/struct.rb', line 14 def delete self.connection.del(@key) end |
#exists? ⇒ Boolean
Returns true if it exists in redis, false otherwise
9 10 11 |
# File 'lib/redstruct/types/struct.rb', line 9 def exists? return self.connection.exists(@key) end |
#expire(ttl) ⇒ Object
18 19 20 |
# File 'lib/redstruct/types/struct.rb', line 18 def expire(ttl) self.connection.expire(@key, ttl) end |
#expire_at(time) ⇒ Object
22 23 24 |
# File 'lib/redstruct/types/struct.rb', line 22 def expire_at(time) self.connection.expire_at(@key, time.to_i) end |
#inspectable_attributes ⇒ Object
:nocov:
35 36 37 |
# File 'lib/redstruct/types/struct.rb', line 35 def inspectable_attributes super.merge(key: @key) end |
#persist ⇒ Object
26 27 28 |
# File 'lib/redstruct/types/struct.rb', line 26 def persist self.connection.persist(@key) end |
#type ⇒ Object
30 31 32 |
# File 'lib/redstruct/types/struct.rb', line 30 def type self.connection.type(@key) end |