PHPackages                             canoma/canoma - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Caching](/categories/caching)
4. /
5. canoma/canoma

AbandonedArchivedLibrary[Caching](/categories/caching)

canoma/canoma
=============

An intuitive and well tested library. That allows you to easily implement consistent hashing in your caching implementation. It's completely back-end agnostic, easy to extend and free to use.

v0.0.3(13y ago)201624WTFPLPHPPHP &gt;=5.3.0

Since Jul 1Pushed 12y ago2 watchersCompare

[ Source](https://github.com/Dynom/Canoma)[ Packagist](https://packagist.org/packages/canoma/canoma)[ RSS](/packages/canoma-canoma/feed)WikiDiscussions development Synced today

READMEChangelogDependencies (1)Versions (5)Used By (0)

Canoma - Consistent hashing for PHP
===================================

[](#canoma---consistent-hashing-for-php)

[![Build Status](https://camo.githubusercontent.com/42dc3e7fc09f3ac98b186807f7168bef7984f9404f29a8a59b3250c33dc02cb7/68747470733a2f2f7365637572652e7472617669732d63692e6f72672f44796e6f6d2f43616e6f6d612e706e673f6272616e63683d646576656c6f706d656e74)](http://travis-ci.org/Dynom/Canoma)

What is Canoma?
---------------

[](#what-is-canoma)

Canoma (CAche NOde MAnager) is a consistent hashing implementation for PHP. It aims to be an intuitive and well tested library. That allows you to easily implement consistent hashing in your caching implementation. It's completely back-end agnostic, easy to extend and free to use. It's developed using TDD.

What problems does Canoma solve?
--------------------------------

[](#what-problems-does-canoma-solve)

It can act as a key component in a reliable distributed caching environment.

All your (application) caches are written to a cache-backend (For example: Redis, Membase, Memcache, etc.), by using Canoma all your keys will be written using a circular designation system. Meaning that keys are spread fairly evenly, with one huge advantage. If one server falls out, the keys will automatically be assigned to another server. This doesn't mean the "next" server, but the server that is next according to the consistent hashing algorithm.

This also works for upscaling. If another server is added, keys are simply distributed evenly again.

Usage
=====

[](#usage)

Requirements
------------

[](#requirements)

PHP 5.3, 5.4 or greater. Both are being tested using Continuous Integration. The test-suite is designed with PHPUnit (3.6.\*), but it will probably run on other versions. Furthermore each hashing adapter will have specific algorithm requirements. All of them should be fairly self-explanatory, (the Md5 adapter uses md5, etc..). To test if they run on your environment, simply run the test-suite:

```
$ cd test/
$ phpunit

```

Quick-start
-----------

[](#quick-start)

The easy way is to add "canoma/canoma" to your composer.json, see: The alternatives are:

- Clone this repo or,
- Download the source:

Example usage
-------------

[](#example-usage)

This section provides some code examples about how to use Canoma. Currently Canoma has very few features, I'm aiming at stability and correctness first. After that, I'll start adding features.

Example usage

```
