Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.0.x will end 8 May 2023 (12 months).
  • Bug fixes for security issues in 4.0.x will end 13 November 2023 (18 months).
  • PHP version: minimum PHP 7.3.0 Note: the minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is also supported.

(no description)

File Size: 244 lines (7 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

Horde_Support_ConsistentHash:: (8 methods):
  __construct()
  get()
  getNodes()
  add()
  addNodes()
  remove()
  hash()
  _updateCircle()


Class: Horde_Support_ConsistentHash  - X-Ref

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-2017 Horde LLC (http://www.horde.org/)

__construct($nodes = array()   X-Ref
Create a new consistent hash, with initial $nodes at $numberOfReplicas

param: array    $nodes             Initial array of nodes to add at $weight.
param: integer  $weight            The weight for the initial node list.
param: integer  $numberOfReplicas  The number of points on the circle to generate for each node.

get($key)   X-Ref
Get the primary node for $key.

param: string $key  The key to look up.
param: string  The primary node for $key.

getNodes($key, $count = 5)   X-Ref
Get an ordered list of nodes for $key.

return: array  An ordered array of nodes.
param: string   $key    The key to look up.
param: integer  $count  The number of nodes to look up.

add($node, $weight = 1)   X-Ref
Add $node with weight $weight

param: mixed $node

addNodes($nodes, $weight = 1)   X-Ref
Add multiple nodes to the hash with the same weight.

param: array    $nodes   An array of nodes.
param: integer  $weight  The weight to add the nodes with.

remove($node)   X-Ref
Remove $node from the hash.

param: mixed $node

hash($key)   X-Ref
Expose the hash function for testing, probing, and extension.

return: string Hash value
param: string $key

_updateCircle()   X-Ref
Maintain the circle and arrays of points.