Class: Redstruct::Hls::Queue

Inherits:
Types::List show all
Includes:
Utils::Scriptable
Defined in:
lib/redstruct/hls/queue.rb

Instance Attribute Summary

Attributes inherited from Types::Base

#key

Instance Method Summary collapse

Methods included from Utils::Scriptable

included

Methods inherited from Types::List

#[], #[]=, #append, #clear, #empty?, #pop, #prepend, #remove, #size, #slice, #to_a

Methods inherited from Types::Struct

#delete, #exists?, #expire, #expire_at, #inspectable_attributes, #persist, #type

Methods included from Utils::Inspectable

#inspect, #inspectable_attributes, #to_s

Methods inherited from Types::Base

#initialize, #inspectable_attributes, #to_h, #with

Constructor Details

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

Instance Method Details

#dequeue(length: 1) ⇒ Object



10
11
12
13
# File 'lib/redstruct/hls/queue.rb', line 10

def dequeue(length: 1)
  elements = dequeue_script(keys: @key, argv: length)
  length == 1 ? elements.first : elements
end

#enqueue(*elements) ⇒ Object



6
7
8
# File 'lib/redstruct/hls/queue.rb', line 6

def enqueue(*elements)
  self.connection.rpush(@key, elements)
end