Skip to content
This repository has been archived by the owner on Jan 9, 2024. It is now read-only.

Improve support for same slot usage #140

Open
Grokzen opened this issue Apr 12, 2016 · 1 comment
Open

Improve support for same slot usage #140

Grokzen opened this issue Apr 12, 2016 · 1 comment
Labels
3.0.0 All issues that will be looked at for 3.0.0 release enhancement

Comments

@Grokzen
Copy link
Owner

Grokzen commented Apr 12, 2016

Currently the solution is designed around functions that has special implementation to support multi slot commands. What needs to be investigated and looked at is to support the more simple method of allowing multikey commands and pipelines to work when they are using the same slot for all keys. This would open up more functionality like WATCH and Transactions and enable the use of multi key functions to run on the server instead of inside the client.

The current proposal is to either have a config option that you send into StrictRedis or to have different classes that supports the different features.

@AngusP
Copy link
Contributor

AngusP commented Mar 8, 2017

Supporting hash tagged keys that have matching tags would be great. I think it'd be a bad idea to try and determine for any key if they're in the same slot that we should use the singular redis command (e.g. BRPOPLPUSH, set operation) as this would result in non-deterministic atomicity as clusters gain or loose nodes and reshard.

The sample implementation for getting the slot of hashtagged keys is given:

def HASH_SLOT(key)
    s = key.index "{"
    if s
        e = key.index "}",s+1
        if e && e != s+1
            key = key[s+1..e-1]
        end
    end
    crc16(key) % 16384
end

Having detection for safe atomic operations would likely give significant speedups in pipelines, large sets and other places, as well as give clusters the same atomicity guarantees as singular Redis servers.

Perhaps a way of enforcing safety would also be useful, such as:

r = rediscluster.StrictRedisCluster(...)
with r.guarantee_sameslot():
    p = r.pipeline()
    p.lpush(_, _)
    ...
    p.execute()

Or some flag that can be passed to methods with custom cluster implementations asking them to raise exceptions if they can't use the redis command instead of falling back on a cluster impl.

@Grokzen Grokzen added the 3.0.0 All issues that will be looked at for 3.0.0 release label Sep 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
3.0.0 All issues that will be looked at for 3.0.0 release enhancement
Projects
None yet
Development

No branches or pull requests

2 participants