Sha256: 0ca31b88f78764fb78ee62e7ae05a1714e5c1ceba7b514798537d4ecbe4c8338

Contents?: true

Size: 829 Bytes

Versions: 5

Compression:

Stored size: 829 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 reconnect
      nodes.each {|node| node.reconnect }
    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

5 entries across 5 versions & 2 rubygems

Version Path
instructure-redis-store-1.0.0.2.instructure1 lib/redis/distributed_store.rb
instructure-redis-store-1.0.0.1.instructure1 lib/redis/distributed_store.rb
redis-store-1.0.0.1 lib/redis/distributed_store.rb
redis-store-1.0.0.rc1 lib/redis/distributed_store.rb
redis-store-1.0.0.beta5 lib/redis/distributed_store.rb