YouTip LogoYouTip

Strings Set

# Redis SET Command [!(#) Redis Strings](#) The Redis SET command sets the value of a given key. If the key already holds another value, SET overwrites the old value, ignoring its type. ### Syntax The basic syntax of the Redis SET command is as follows: redis 127.0.0.1:6379> SET KEY_NAME VALUE ### Available Versions >= 1.0.0 ### Return Value In Redis versions prior to 2.6.12, the SET command always returns OK. Starting from Redis 2.6.12, SET returns OK only when the set operation completes successfully. ### Example First, let's create a key in Redis and set its value. # Setting a key that does not exist redis 127.0.0.1:6379> SET key "value" OK redis 127.0.0.1:6379> GET key "value"# Setting an existing key redis 127.0.0.1:6379> SET key "new-value" OK redis 127.0.0.1:6379> GET key "new-value" [!(#) Redis Strings](#)
← Strings GetRedis Strings β†’