Class: Redstruct::Types::Struct

Inherits:
Base
  • Object
show all
Includes:
Utils::Inspectable
Defined in:
lib/redstruct/types/struct.rb

Direct Known Subclasses

Hash, List, Set, SortedSet, String

Instance Attribute Summary

Attributes inherited from Base

#key

Instance Method Summary collapse

Methods included from Utils::Inspectable

#inspect, #to_s

Methods inherited from Base

#initialize, #to_h, #with

Constructor Details

This class inherits a constructor from Redstruct::Types::Base

Instance Method Details

#deleteFixnum

Returns 0 if nothing was deleted in the DB, 1 if it was.

Returns:

  • (Fixnum)

    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

Returns:

  • (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_attributesObject

:nocov:



35
36
37
# File 'lib/redstruct/types/struct.rb', line 35

def inspectable_attributes
  super.merge(key: @key)
end

#persistObject



26
27
28
# File 'lib/redstruct/types/struct.rb', line 26

def persist
  self.connection.persist(@key)
end

#typeObject



30
31
32
# File 'lib/redstruct/types/struct.rb', line 30

def type
  self.connection.type(@key)
end