Class: RedBlocks::InstantSet

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

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.



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

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 = Digest::SHA2.hexdigest value.sort.uniq.join(",")
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



14
15
16
# File 'lib/red_blocks/instant_set.rb', line 14

def cache_time
  0
end

#getObject



18
19
20
# File 'lib/red_blocks/instant_set.rb', line 18

def get
  value
end

#key_suffixObject



22
23
24
# File 'lib/red_blocks/instant_set.rb', line 22

def key_suffix
  suffix
end