Class: RedBlocks::InstantSet

Inherits:
Set
  • Object
show all
Defined in:
lib/red_blocks/instant_set.rb

Constant Summary collapse

RAND_MAX =
100_000_000

Instance Attribute Summary collapse

Attributes inherited from Set

#weight

Instance Method Summary collapse

Methods inherited from Set

#disabled?, #expiration_time, #expression, #ids, #key, key_pattern, #label, #size, #update!, #update_if_disabled!

Methods included from SetOptimizer

#unset

Methods included from SetUtils

included, #joined_key, #normalize_entries, #validate_array_entry, #validate_entries!

Constructor Details

#initialize(value) ⇒ InstantSet

Returns a new instance of InstantSet.



7
8
9
10
11
12
13
14
# File 'lib/red_blocks/instant_set.rb', line 7

def initialize(value)
  unless value.is_a?(Array)
    raise TypeError.new("Expect value as Array, but got #{ids_or_ids_with_scores.class}")
  end

  @value = value
  @suffix = rand(RAND_MAX)
end

Instance Attribute Details

#suffixObject (readonly)

Returns the value of attribute suffix.



3
4
5
# File 'lib/red_blocks/instant_set.rb', line 3

def suffix
  @suffix
end

#valueObject (readonly)

Returns the value of attribute value.



3
4
5
# File 'lib/red_blocks/instant_set.rb', line 3

def value
  @value
end

Instance Method Details

#cache_timeObject



16
17
18
# File 'lib/red_blocks/instant_set.rb', line 16

def cache_time
  0
end

#getObject



20
21
22
# File 'lib/red_blocks/instant_set.rb', line 20

def get
  value
end

#key_suffixObject



24
25
26
# File 'lib/red_blocks/instant_set.rb', line 24

def key_suffix
  suffix
end