keyslot (cluster)

redis-py · database, hash-slot, cluster-routing, command-routing, key-sharding, infra

Computes the Redis cluster hash slot for a given key using the client's encoder, enabling sharding and command routing.

    def keyslot(self, key: EncodableT) -> int:
        """
        Find the keyslot for a given key.

        See: https://redis.io/docs/manual/scaling/#redis-cluster-data-sharding
        """
        return key_slot(self.encoder.encode(key))

See the full source, get the GitHub permalink, and search 40K more like it.

Get a free API key