skip to Main Content

Hey working with redisJSON
NodeJS
package npm Redis 4.3.1

Key (userID):(Country) with values Json

Example

data = {
"info": {
"name":"test",
"email": "test@test,test"
},
"suppliers": {
"s1": 1,
"s2": 22
},
"suppliersCap": {
"s1": 0,
"s2": 10
}
}

redis.json.set(’22:AU’, ‘.’, data);

now I try to add TTL for 5 minutes on the specific key in the JSON
for example on this key

22:AU .data.suppliersCap.s2, after 5 minutes the cap will be 0;

bit this not works

redis.json.set(22:AU, ‘.data.suppliersCap.s2’, {
EX: 300
});

2

Answers


  1. You cannot set TTL on an inner element of a RedisJSON object.

    Note: It can be done only on an entire RedisJSON object.

    Login or Signup to reply.
  2. NX and XX are the only valid modifiers for the command:

    redisClient.json.set(
      key: string, 
      path: string, 
      json: RedisJSON, 
      options?: NX | XX | undefined
    ): Promise<"OK" | null>
    

    enter image description here

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search