Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.2.x will end 22 April 2024 (12 months).
  • Bug fixes for security issues in 4.2.x will end 7 October 2024 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.1.x is supported too.

(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.

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

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.

param: string $key
return: string Hash value

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