phpRedis migration to cluster and consistent hashing

倾然丶 夕夏残阳落幕 提交于 2021-02-18 07:59:21

问题


We are currently using PhpRedis extension and our code is written using the class Redis from the PhpRedis. But now we are migrating to a redis cluster.

Is it possible to use the Class Redis to connect to redis cluster? or do we need to re-write our code and use the Class RedisArray?

We ll need to have consistent hashing too. We have added keys like this {user}:1 so we can do consistent hashing later.

main problem is taking all the code written using the class Redis and changing it to RedisArray.

I am new to redis so please provide some advice

Thanks


回答1:


This is a email reply from one of the author of PHPredis Nicolas. I thank him for taking the time for replying to me.

Hi,

I just want to start by clarifying that the RedisArray class does not provide a client library for Redis Cluster. It uses consistent hashing to distribute data to a set of independent Redis nodes, and provides a common interface so that developers can avoid having to write the distribution layer themselves.

Phpredis does not currently support Redis Cluster.

Addressing your questions:

  • It is possible to connect to 4 redis servers with RedisArray.
  • RedisArray provides consistent hashing and you can select which part of the key is to be used for the distribution.
  • The RedisArray class has a few limitations. In particular, multi-key commands (e.g. ZINTERSTORE) are mostly executed on one node, but some do offer integrated distribution (e.g. DEL, MGET).

To learn more about the RedisArray class, please refer to the documentation on GitHub.

They have added support for Redis cluster now https://github.com/phpredis/phpredis/blob/feature/redis_cluster/cluster.markdown#readme



来源:https://stackoverflow.com/questions/20416781/phpredis-migration-to-cluster-and-consistent-hashing

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!