Overview

Packages

  • Support

Classes

  • Horde_Support_Array
  • Horde_Support_Backtrace
  • Horde_Support_CombineStream
  • Horde_Support_ConsistentHash
  • Horde_Support_Guid
  • Horde_Support_Inflector
  • Horde_Support_Memory
  • Horde_Support_Numerizer
  • Horde_Support_Numerizer_Locale_Base
  • Horde_Support_Numerizer_Locale_De
  • Horde_Support_Numerizer_Locale_Pt
  • Horde_Support_Randomid
  • Horde_Support_Stack
  • Horde_Support_StringStream
  • Horde_Support_Stub
  • Horde_Support_Timer
  • Horde_Support_Uuid
  • Overview
  • Package
  • Class
  • Tree

Class Horde_Support_ConsistentHash

For a thorough description of consistent hashing, see http://www.spiteful.com/2008/03/17/programmers-toolbox-part-3-consistent-hashing/, and also the original paper: http://www8.org/w8-papers/2a-webserver/caching/paper2.html

Copyright 2007-2012 Horde LLC (http://www.horde.org/)

Package: Support
Category: Horde
License: http://www.horde.org/licenses/bsd
Located at Horde/Support/ConsistentHash.php
Methods summary
public
# __construct( array $nodes = array(), integer $weight = 1, integer $numberOfReplicas = 100 )

Create a new consistent hash, with initial $nodes at $numberOfReplicas

Create a new consistent hash, with initial $nodes at $numberOfReplicas

Parameters

$nodes
Initial array of nodes to add at $weight.
$weight
The weight for the initial node list.
$numberOfReplicas
The number of points on the circle to generate for each node.
public
# get( string $key )

Get the primary node for $key.

Get the primary node for $key.

Parameters

$key
The key to look up.
public array
# getNodes( string $key, integer $count = 5 )

Get an ordered list of nodes for $key.

Get an ordered list of nodes for $key.

Parameters

$key
The key to look up.
$count
The number of nodes to look up.

Returns

array
An ordered array of nodes.
public
# add( mixed $node, mixed $weight = 1 )

Add $node with weight $weight

Add $node with weight $weight

Parameters

$node
$weight
public
# addNodes( array $nodes, integer $weight = 1 )

Add multiple nodes to the hash with the same weight.

Add multiple nodes to the hash with the same weight.

Parameters

$nodes
An array of nodes.
$weight
The weight to add the nodes with.
public
# remove( mixed $node )

Remove $node from the hash.

Remove $node from the hash.

Parameters

$node
public string
# hash( string $key )

Expose the hash function for testing, probing, and extension.

Expose the hash function for testing, probing, and extension.

Parameters

$key

Returns

string
Hash value
API documentation generated by ApiGen