Skip to content

ZRANGE.UNWATCH

The ZRANGE.UNWATCH command is a feature to stop receiving updates on a sorted set.

Protocol Support

ProtocolSupported
TCP-RESP
HTTP
WebSocket

Syntax

Terminal window
ZRANGE.UNWATCH <fingerprint>

Parameters

ParameterDescriptionTypeRequired
fingerprintFingerprint returned as part of the zrange.watch queryStringYes

Return Value

ConditionReturn Value
Command is successfulOK

Behavior

  • The client unsubscribes from the sorted set specified with the key.

Errors

  1. Missing fingerprint
    • Error Message: (error) ERROR wrong number of arguments for 'zrange.unwatch' command
    • Occurs if no fingerprint is provided.

Example Usage

Basic Usage

Let’s explore a practical example of using the ZRANGE.WATCH command to create a real-time submission leaderboard for a game match.

Terminal window
127.0.0.1:7379> ZRANGE.WATCH match:100 0 1 REV WITHSCORES
ZRANGE.WATCH
Command: ZRANGE
Fingerprint: 4016579015
Data:

When the sorted set is updated using following set of commands from another client:

Terminal window
127.0.0.1:7379> ZADD match:100 1 "player1"
OK
127.0.0.1:7379> ZADD match:100 2 "player2"
OK
127.0.0.1:7379> ZADD match:100 1 "player3"
OK
127.0.0.1:7379> ZADD match:100 4 "player4"
OK

The client will receive a message similar to the following:

Terminal window
Command: ZRANGE
Fingerprint: 4016579015
Data: [{1 player1}]
Command: ZRANGE
Fingerprint: 4016579015
Data: [{2 player2}]
Command: ZRANGE
Fingerprint: 4016579015
Data: [{2 player2}]
Command: ZRANGE
Fingerprint: 4016579015
Data: [{4 player4}]

To stop receiving updates on the key, use the ZRANGE.UNWATCH command.

Terminal window
127.0.0.1:7379> ZRANGE.UNWATCH 4016579015
OK

Notes

Use the ZRANGE.WATCH command to subscribe to a key. This will allow the client to receive updates on the sorted set. Please refer to the ZRANGE.WATCH command documentation for more information.

following are the related commands to ZRANGE.UNWATCH: