Sha256: cf498780974c353af9640904a06cd35712b2ce7b017f2d63bd68649c5f8c3858

Contents?: true

Size: 535 Bytes

Versions: 1

Compression:

Stored size: 535 Bytes

Contents

# You'd normally call this a set, but Redis already has another data type for that
class Kredis::Types::UniqueList < Kredis::Types::List
  proxying :multi, :ltrim, :exists?

  attr_accessor :typed, :limit

  def prepend(elements)
    multi do
      remove elements
      super
      ltrim 0, (limit - 1) if limit
    end if Array(elements).flatten.any?
  end

  def append(elements)
    multi do
      remove elements
      super
      ltrim (limit - 1), -1 if limit
    end if Array(elements).flatten.any?
  end
  alias << append
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
kredis-1.0.0 lib/kredis/types/unique_list.rb