Sha256: 26884fcf5a8cce1ecc7ca9979a9493351f01e4934574a224f9affcc880b631fc
Contents?: true
Size: 459 Bytes
Versions: 2
Compression:
Stored size: 459 Bytes
Contents
class FastCache::BasicRouter attr_reader :bucket_delegate, :hash_delegate def initialize(nodes, bucket_class = FastCache::ModulusBucket, hash_class = FastCache::CRC32) @nodes = nodes @bucket_delegate = bucket_class.new(nodes) @hash_delegate = hash_class end def each(&b) @nodes.each(&b) end def route(key, &b) digest = @hash_delegate.new(key.to_s).digest @bucket_delegate.select(digest.unpack('N').first, &b) end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
binary42-fastcache-0.2 | lib/fastcache/routing/basic_router.rb |
binary42-fastcache-0.3 | lib/fastcache/routing/basic_router.rb |