Sha256: 9b43d6d3eee6c608f2d06a58b2ef8aae9405a46beab1fa2579f0f6a2c91ff0a5

Contents?: true

Size: 760 Bytes

Versions: 3

Compression:

Stored size: 760 Bytes

Contents

class Redis
  class DistributedStore < Distributed
    attr_reader :ring

    def initialize(addresses, options = { })
      nodes = addresses.map do |address|
        ::Redis::Store.new address
      end
      _extend_namespace options
      @ring = Redis::HashRing.new nodes
    end

    def nodes
      ring.nodes
    end

    def set(key, value, options = nil)
      node_for(key).set(key, value, options)
    end

    def get(key, options = nil)
      node_for(key).get(key, options)
    end

    def setnx(key, value, options = nil)
      node_for(key).setnx(key, value, options)
    end

    private
      def _extend_namespace(options)
        @namespace = options[:namespace]
        extend ::Redis::Store::Namespace if @namespace
      end
  end
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
redis-store-1.0.0.beta4 lib/redis/distributed_store.rb
nono-redis-store-1.0.0 lib/redis/distributed_store.rb
redis-store-1.0.0.beta3 lib/redis/distributed_store.rb