天天看点

sharded_eredis

Copyright (c) 2012 PlayMesh, Inc.

sharded_eredis is collection of pools of Redis clients, using eredis and poolboy. Each pool points to a different shard.

This project modifies the original repository by including a consistent hashing library to simplify presharding, suggested by antirez. Read the original blogpost here.

The name has been changed so as not to induce confusion for those originally using hiroeorz's sharded_eredis; the functionality has changed significantly.

eredis: https://github.com/wooga/eredis

poolboy: https://github.com/devinus/poolboy

This library uses Redis but in a distributed fashion. Multi-object operations are no longer guaranteed to be atomic and are not supported by this library. Examples include multisets, multigets, source-destination operations, and multi-object transactions. Transactions technically still work if all keys involved in the transaction are on the same machine but the Redis transaction was not built to be distributed.

git clone git://github.com/jeremyong/sharded_eredis.git

cd eredis_pool

make get-deps

make

make test

Add new pools. This configuration specifies 4 shards.

You can include this using the erlang <code>-config</code> option.

The <code>global_or_local</code> option is used to determine whether the pools are registered as local or global. Personally, I start this application on every instance and run pools on each instance locally to minimize network latency.

application start.

key-value set and get

Note that the name of the pool does not need to be supplied with each query (in contrast to prior behavior). The library will automatically determine which pool associated to the correct shard should be invoked.

The Redis documentation can be referred to here.

本文作者:陈群

本文来自云栖社区合作伙伴rediscn,了解相关信息可以关注redis.cn网站。

继续阅读