Since almost a year or so, I've been programming less and managing more.. Well that obviously begged for a side projected and voila, that is the story why I started this new project.
I've always had an interest for distributed systems and once I learned about Consistent Hashing I was blown by the simplicity, yet it's massive impact and effectiveness. I can start a massive buzz-word galore at this point, but I much rather move over to my latest project, CANOMA.
If you just want to see code, head on here: github.com/Dynom/Canoma
CANOMA, short for Cache Node Manager, is a well tested PHP library that allows for very easy implementation of a distributed caching strategy. It supports various algorithms, ranging from fast and simple to complex and slow. I've also included a tool to help you choose the best algorithm and settings for your infrastructure, since this is very dependent on the amount of caching nodes, the amount of expected cache keys and the amount of redundancy you want to have.
Some code
If you put most of your setting in configuration, construction is as easy as:
$factory = new \Canoma\Factory;
$manager = $factory->createManager($yourConfiguration);
After this, you use it as follows:
$node = $manager->getNodeForString($cacheKey);
// $node could look like: "tcp://cache07.pool0.example.org"
$yourCacheBackend->connectTo($node)->save($payload);
Many fine clients already offer this functionality built-in (e.g.:Predis, https://github.com/nrk/predis ). Canoma, however, tries to offer only a client-side sharding implementation using consistent hashing and offers various algorithms.
Thanks for reading!