Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR accomplishes sending the read queries to the replicas.
This is managed via specifying a read_replica_flag during the connection process, or alternatively specifying the same in the env args.
Depending on the state of the read replica flags, additional pools are maintained which connects to the replica nodes, and based on the type of queries appropriate pool is chosen and the query is sent to the node.
The query used for the replica are:
zrange
touch
zrevrangebylex
dump
zcount
hmget
hgetall
sinter
georadius_ro
exists
zrevrank
zrangebyscore
dbsize
lrange
type
zlexcount
zrank
llen
geodist
bitcount
zrangebylex
sdiff
hscan
hexists
randomkey
zrevrangebyscore
zrevrange
pttl
zcard
ttl
zscore
smembers
scan
substr
geohash
georadiusbymember_ro
geopos
getrange
strlen
sscan
hkeys
sismember
hstrlen
mget
get
srandmember
hvals
psync
sync
object
pfcount
bitpos
lindex
keys
getbit
memory
scard
zscan
hget
sunion
hlen
(I have used filtered out the readonly commands which can be obtained using the
COMMANDS
function in redis).EVAL and MULTI EXEC are sent to the master by default. Also everything associate with optimistic locking transaction is sent to the master nodes.
The API's are backward compatible as you have to specify the read_replica_flag during the startup.