How do i overwrite a key value only if it exists on redis?



  • Also see: https://www.lightnetics.com/post/10426

    This article assumes you have installed and connected to the redis server.

    The redis set command has an XX option to do this.

    If the key value exists then is will overwrite it.

    127.0.0.1:6379> set myfavsong "everybody's free"
    OK
    127.0.0.1:6379> get myfavsong
    "everybody's free"
    127.0.0.1:6379> set myfavsong "let the music play" xx
    OK
    127.0.0.1:6379> get myfavsong
    "let the music play"
    127.0.0.1:6379> 
    

Log in to reply
 

© Lightnetics 2024