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