-
Notifications
You must be signed in to change notification settings - Fork 1k
WATCH
Arpit Bhayani edited this page May 30, 2024
·
3 revisions
WATCH
watches a query and notifies you in real-time.
>>> WATCH KEYS 'users:1:*' EVENT put_key RETURN KEY VALUE
0) users:1:product_view:a
1) "{\"platform\":\"android\"}" <--- value
The above statement subscribes to the connected client to watch for new keys matching the above pattern. The subscribers receive the data requested i.e. KEY, VALUE as a list.
>>> WATCH KEYS 'users:1:*' EVENT put_key WINDOW 1s GROUP_BY (KEY) RETURN (KEY VALUE)
0) users:1:product_view:a
0) users:1:product_view:a
1) "{\"platform\":\"android\"}" <--- value
2) users:1:product_view:a
3) "{\"platform\":\"ios\"}" <--- value
1) users:1:product_view:b
.
.
.
The JSON equivalent of response is
[
"users:1:product_view:a": [
["users:1:product_view:a", "{\"platform\":\"android\"}"],
["users:1:product_view:a", "{\"platform\":\"ios
],
"users:1:product_view:b": [
...
],
]
The above statement subscribes to the connected client to watch for new keys matching the pattern. The subscribers receive the data windowed by 1 second (not sliding window), group by key
, and return KEY, VALUE as a list.