English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The Redis SET command is used to set the value of the given key. If the key already stores another value, SET overwrites the old value and ignores the type.
Basic Syntax of Redis SET Command
redis 127.0.0.1:6379> SET KEY_NAME VALUE
>= 1.0.0
In Redis 2.6.12 In previous versions, the SET command always returned OK.
From Redis 2.6.12 Starting from this version, SET returns OK only after the setting operation is successfully completed.
Firstly, we create a key and set its value in Redis.
# Set the non-existing key redis 127.0.0.1:6379> SET key "value" OK redis 127.0.0.1:6379> GET key "value" # Set the existing key redis 127.0.0.1:6379> SET key "new-value" OK redis 127.0.0.1:6379> GET key "new-value"