Class: Kredis::Types::UniqueList
- Defined in:
- lib/kredis/types/unique_list.rb
Overview
You’d normally call this a set, but Redis already has another data type for that
Instance Attribute Summary collapse
-
#limit ⇒ Object
Returns the value of attribute limit.
-
#typed ⇒ Object
Returns the value of attribute typed.
Attributes inherited from Proxying
Instance Method Summary collapse
Methods inherited from List
Methods inherited from Proxying
Constructor Details
This class inherits a constructor from Kredis::Types::Proxying
Instance Attribute Details
#limit ⇒ Object
Returns the value of attribute limit.
5 6 7 |
# File 'lib/kredis/types/unique_list.rb', line 5 def limit @limit end |
#typed ⇒ Object
Returns the value of attribute typed.
5 6 7 |
# File 'lib/kredis/types/unique_list.rb', line 5 def typed @typed end |
Instance Method Details
#append(elements) ⇒ Object Also known as: <<
15 16 17 18 19 20 21 |
# File 'lib/kredis/types/unique_list.rb', line 15 def append(elements) multi do remove elements super ltrim (limit - 1), -1 if limit end if Array(elements).flatten.any? end |
#prepend(elements) ⇒ Object
7 8 9 10 11 12 13 |
# File 'lib/kredis/types/unique_list.rb', line 7 def prepend(elements) multi do remove elements super ltrim 0, (limit - 1) if limit end if Array(elements).flatten.any? end |