STRINGS Intro

Apply for Redis Developer Course Redis Regular Inspection / Technical Support Redis Enterprise Server

key-value

STRINGS is a one-to-one key-value relationship.
Lists, Sets, Sorted Sets, and Hashes are one-to-many.

Key/Value Data type: Binary-safe strings

Binary-safe strings may contain letters, digits, CJK characters, images, and so on.
That applies not only to the value but also to the key.

key/value maximum length: 512 megabytes

The maximum length of both key and value is 512MB.

key design

  • Keep keys reasonably sized.
    Readable: "user_1000_email"
    Memory-saving: "u1000e"
  • Use a separator between words in a key.
    For example, '_' makes keys easier to read.
    If you plan to use SQL (SELECT) on Enterprise, '_' is recommended over other separators.

Command summary

  • SET: SET, SETNX, SETEX, SETPEX, MSET, MSETNX, APPEND, SETRANGE
  • GET: GET, MGET, GETRANGE, STRLEN
  • INCR: INCR, DECR, INCRBY, DECRBY, INCRBYFLOAT

STRINGS command list

CommandsVersionSyntaxDescription
DECR1.0.0keyDecrement by 1. New keys are set to -1.
DECRBY1.0.0key decrementDecrement by decrement. New keys are set to -decrement.
DEL1.0.0key [key ...]Delete data
GET1.0.0keyGet the value
GETSET1.0.0key valueGet the old value and set a new one
INCR1.0.0keyIncrement by 1. New keys are set to 1.
INCRBY1.0.0key incrementIncrement by increment. New keys are set to increment.
MGET1.0.0key [key ...]Get multiple values at once
SET1.0.0key value [EX seconds]
[PX milliseconds] [NX|XX]
Set a value. Overwrites an existing key.
SETNX1.0.0key valueSet only if the key does not exist
MSET1.0.1key value [key value ...]Set multiple values at once
MSETNX1.0.1key value [key value ...]Set multiple values only if none of the keys exist
APPEND2.0.0key valueAppend data. Creates the key if it is missing
SETEX2.0.0key seconds valueSet a value that expires after seconds
SETRANGE2.2.0key offset valueOverwrite from the given offset
STRLEN2.2.0keyReturn the byte length of the value
GETRANGE2.4.0key start endGet a substring of the value
INCRBYFLOAT2.6.0key incrementIncrement by a float. New keys are set to increment.
PSETEX2.6.0key milliseconds value Set a value that expires after milliseconds
STRALGO6.0.0STRALGO LCS Measure how similar two strings are
GETEX6.2.0key [EX seconds] Get a value and set expire
GETDEL6.2.0key Get a value and delete it

Total : 22


STRINGS command overview



Redis Internal: STRING data structure

  • STRING data structure
    Internally STRING is split into integer and string encodings. Integers are shared or independent. Strings are EMBSTR (allocated together) or RAW (allocated separately).   This page covers the internal STRING data structure.

PDF manual


<< Commands STRINGS SET >>

Email 답글이 올라오면 이메일로 알려드리겠습니다.