class Kredis::Types::OrderedSet
def append(elements)
def append(elements) insert(elements) end
def base_score
def base_score process_start_time + process_uptime end
def elements
def elements strings_to_types(zrange(0, -1) || [], typed) end
def include?(element)
def include?(element) !!zscore(type_to_string(element, typed)) end
def insert(elements, prepending: false)
def insert(elements, prepending: false) elements = Array(elements) return if elements.empty? elements_with_scores = types_to_strings(elements, typed).map.with_index do |element, index| incremental_score = index * 0.000001 score = if prepending -base_score - incremental_score else base_score + incremental_score end [ score, element ] end multi do zadd(elements_with_scores) trim(from_beginning: prepending) end end
def limit=(limit)
def limit=(limit) raise "Limit must be greater than 0" if limit && limit <= 0 @limit = limit end
def prepend(elements)
def prepend(elements) insert(elements, prepending: true) end
def process_start_time
def process_start_time @process_start_time ||= unproxied_redis.time.join(".").to_f - process_uptime end
def process_uptime
def process_uptime Process.clock_gettime(Process::CLOCK_MONOTONIC) end
def remove(*elements)
def remove(*elements) zrem(types_to_strings(elements, typed)) end
def set_default
def set_default append default end
def trim(from_beginning:)
def trim(from_beginning:) return unless limit if from_beginning zremrangebyrank(limit, -1) else zremrangebyrank(0, -(limit + 1)) end end