Sha256: 6b39f56c7bceb7c4f5882e8e1cdc2bec690d3abbdd536f7738bb3347b494b25c

Contents?: true

Size: 361 Bytes

Versions: 2

Compression:

Stored size: 361 Bytes

Contents

class FastCache::ModulusBucket

  def initialize(nodes)
    @nodes = nodes
  end

  def select(hash)
    count = @nodes.size
    count.times do |i|
      begin
        break yield(@nodes[(hash + i) % count])
      rescue FastCache::Memcache::ProtocolError
        next
      end
      raise 'Unable to find suitable node to communicate with'
    end
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
binary42-fastcache-0.2 lib/fastcache/bucket/modulus.rb
binary42-fastcache-0.3 lib/fastcache/bucket/modulus.rb