SET key value [NX | XX] GET [ EX | PX | EXAT | PXAT | KEEPTTL]
- Let’s break down the options for the
set
commands in redisSET
for save data- key : key of value
- value : value of data
- optional keywords of SET (update, insert or update)
NX
: only set the key if it does not already exists, (insert update). exp:SET totalemployee 1000 NX
XX
: only set the key if it already exists (update).SET totalemployee 1000 XX
- Options Time To Live (TTL) in set Commands
EX
: this options sets the expiration in seconds.- exp
SET totalemployee 2000 EX
10
- exp
PX
: Similar to options ttl ex, px options sets the expiration in miliseconds.- exp :
SET totalemployee 5000 PX 10000
- exp :
EXAT
: Set Expiration in unix timestamp;- Go to the https://timestamp.online/timestamp/ to convert online timestamp
- 2024-02-27 22:00:00 = 1709042400
- exp :
SET totalemployee 1234 EXAT 1709042400
- PXAT : Similar expiration with EXAT , but in miliseconds.
- exp :
SET totalemployee 1234 EXAT 1709042400000
- exp :
- KEEPTTL : keywords comands to keep the TTL before.
- exp:
SET totalemployee 100 KEEPTTL
- exp:
Learning by Doing, and Keep the Notes..