Sha256: fbd47258c5fbe85daefb09b4eee1fa94157348c1b73b825ff859a1265413b21d
Contents?: true
Size: 524 Bytes
Versions: 2
Compression:
Stored size: 524 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 def initialize(redis, key, limit: nil) @limit = limit super redis, key end def prepend(elements) multi do remove elements super ltrim 0, (@limit - 1) if @limit end if Array(elements).any? end def append(elements) multi do remove elements super ltrim (@limit - 1), -1 if @limit end if Array(elements).any? end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
kredis-0.1.2 | lib/kredis/types/unique_list.rb |
kredis-0.1.1 | lib/kredis/types/unique_list.rb |