Sha256: 57631d2ff7497c4aeea53ec29a624c37550bc7cb3659ded179d057a0044c9b46

Contents?: true

Size: 579 Bytes

Versions: 3

Compression:

Stored size: 579 Bytes

Contents

# frozen_string_literal: true

module Split
  # Simplifies the interface to Redis.
  class RedisInterface
    def initialize
      self.redis = Split.redis
    end

    def persist_list(list_name, list_values)
      if list_values.length > 0
        redis.multi do |multi|
          tmp_list = "#{list_name}_tmp"
          multi.rpush(tmp_list, list_values)
          multi.rename(tmp_list, list_name)
        end
      end

      list_values
    end

    def add_to_set(set_name, value)
      redis.sadd(set_name, value)
    end

    private

    attr_accessor :redis
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
split-4.0.1 lib/split/redis_interface.rb
split-4.0.0.pre2 lib/split/redis_interface.rb
split-4.0.0.pre lib/split/redis_interface.rb