Data type
Strings
The string is the most basic type of REDIS data. Redis strings are binary safe, which means that a Redis string can contain any type of data, such as a JPEG image or a serialized Ruby object.
A string can be up to 512M maximum.
You can use Redis strings to do a lot of interesting things, such as:
(1) can be used as an atomic counter. In conjunction with the INCR command: Incr,decr,incrby
(2) extending a string with the append command
(3) Random access to substrings using GetRange and SetRange commands
(4) Use the Getbit and Setbit commands to access the bits of the string
Lists
The Redis list stores strings in the order in which they are inserted. It supports insertion at the head and trailing inserts.
The Lpush command inserts a new element into the head, and Rpush inserts it at the tail. The list is created automatically when an element is inserted into an empty key. Similarly, if an operation clears the list
element, then key is also cleared. These are very handy syntax features because all list commands behave consistently when you perform an operation on a nonexistent key.
The following is an example of an operation performed on Lsit:
Lpush MyList A # Now the list is "a"
Lpush MyList B # Now the list is "B", "a"
Rpush MyList C # Now the list is "B", "A", "C"
Each list supports a maximum of 2 of 32 square-1 elements, or 4,294,967,295 elements.
In terms of time efficiency, the list supports the insertion or deletion of a constant time, even if it contains millions of elements. However, the elements in the middle of the list operate at an O (N) time.
Introduction to Redis Data types 1