flâneur

Redis Strings | Redis

redis.io · 8,804 words · saved by 1 readers

Redis strings store sequences of bytes, including text, serialized objects, and binary arrays. As such, strings are the simplest type of value you can associate with a Redis key. They're often used for caching, but they support additional functionality that lets you implement counters and perform bitwise operations, too. Since Redis keys are strings, when we use the string type as a value too, we are mapping a string to another string. The string data type is useful for a number of use cases, like caching HTML fragments or pages. As you can see using the SET and the GET commands are the way we set and retrieve a string value. Note that SET will replace any existing value already stored into the key, in the case that the key already exists, even if the key is associated with a non-string value. So SET performs an assignment. Values can be strings (including binary data) of every kind, for instance you can store a jpeg image inside a value. A value can't be bigger than 512 MB. The SET co

Introduction to Redis strings APPEND v2.0.0 @write @string @fast Appends a string to the value of a key. Creates the key if it doesn't exist. O(1). The amortized time complexity is O(1) assuming the appended value is small and the already present value is of any size, since the dynamic string library used by Redis will double the free space available on every reallocation. DECR v1.0.0 @write @string @fast Decrements the integer value of a key by one. Uses 0 as initial value if the key doesn't exist. O(1) DECRBY v1.0.0 @write @string @fast Decrements a number from the…

related reading