SET key value [NX | XX] GET [ EX | PX | EXAT | PXAT | KEEPTTL]

  • Let’s break down the options for the set commands in redis
    • SET 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
    • redis set
    • Options Time To Live (TTL) in set Commands
      • EX : this options sets the expiration in seconds.
        • exp SET totalemployee 2000 EX 10
        • Set With EX
      • PX : Similar to options ttl ex, px options sets the expiration in miliseconds.
        • exp : SET totalemployee 5000 PX 10000
        • Set With PX
      • EXAT : Set Expiration in unix timestamp;
      • PXAT : Similar expiration with EXAT , but in miliseconds.
        • exp : SET totalemployee 1234 EXAT 1709042400000
      • KEEPTTL : keywords comands to keep the TTL before.
        • exp: SET totalemployee 100 KEEPTTL
        • set with KeepTTL

Learning by Doing, and Keep the Notes..

Tagged with: