0

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 });

IaMus90
  • 13
  • 1
  • 4

2 Answers2

1

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

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

sazzad
  • 5,740
  • 6
  • 25
  • 42
0

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

Max Ivanov
  • 5,695
  • 38
  • 52