Redis String DataType

  • Most powerful data structure in Redis
  • Strings are binary safe in Redis
    • Redis string is a sequence of bytes
    • A binary-safe string is one that can consist of any characters (bytes)
    • Strings in Redis are binary safe, meaning they have a known length not determined by any special terminating characters.
    • For example, many programming languages use the 0x00 character as an end-of-string marker, so in that sense a binary safe string is one that can consist of these.
    • Thus, you can store anything up to 512 megabytes in one string.
    • Redis Strings are binary safe, this means that a Redis string can contain any kind of data, for instance a JPEG image or a serialized Ruby object.
    • Any object can be serialized to a string
  • String can behave as a random access vertor too
  • Large data like a wikipedia page can be encoded into small format and stored as a string
  • Max Size 512 MB

Use cases

  • Storing static website pages
  • website uses Redis database itself to serve as a static page
  • Caching
  • Stats – Daily user count etc

Leave a Comment