redis 命令行相关
当搭建好一个redis 或是twemproxy之后,可以直接采用如下命令来操作redis集群1
2# 连接上redis server
redis-cli -p port
剩下的就是操作redis的命令了
命令参考 https://redis.io/commands
Error: Protocol error, got “{“ as reply type byte
It is because twemproxy will listen on two ports when it starts, one of them is port 22222(by default, you can set it with ‘-s’), it is used for monitoring, if you connect to it, the error occurs
So, connect to another port
Hash Tags 功能
Hash Tags enables you to use part of the key for calculating the hash. When the hash tag is present, we use part of the key within the tag as the key to be used for consistent hashing. Otherwise, we use the full key as is. Hash tags enable you to map different keys to the same server as long as the part of the key within the tag is the same.
For example, the configuration of server pool beta, also shown below, specifies a two character hash_tag string - “{}”. This means that keys “user:{user1}:ids” and “user:{user1}:tweets” map to the same server because we compute the hash on “user1”. For a key like “user:user1:ids”, we use the entire string “user:user1:ids” to compute the hash and it may map to a different server.
1 | beta: |
参考链接:https://github.com/twitter/twemproxy/blob/master/notes/recommendation.md#hash-tags