Strings, lists, hashes, sets, and sorted sets are the basic data types in Redis. Each type has its strengths and should be used appropriately to take complete advantage of these strengths. In this section, we will discuss each type briefly.
Note
To view all the available commands and data types in Redis, visit http://redis.io/commands.
Strings are the most basic data type in Redis. This basic type is binary safe and is used to create more complex data types such as lists and sets. A string value can hold up to 512 MB of data. Being the most basic type, it can be used to hold anything such as a binary stream of images, data in JSON format, generated HTML cached for faster delivery, and many other use cases.
From Redis 2.6.12, we can even set expiry information in seconds or milliseconds as part of the SET
command. Prior to 2.6.12, we can set expiry information through the SETEX
command with seconds' precision.
SET mykey myvalue EX 5 GET mykey...