Article Directory
键 (Key)
# 查看所有键
& keys *
# 判断某个键是否存在
& exists key的名字
# 转移键到其他库
& move key db
# 为给定键设置过期时间
& expire key 秒钟
# 查看还有多少秒过期(返回-2已过期,-1永不过期)
& ttl key
# 查看你的key是什么类型
& type key
1: String (String)
- Redis string is the most basic type, we can be understood as a Key, one for Value.
- Binary safe type string. Redis meaning of string can contain any data, such as jpg pictures
- redis basic string data type is a type, a redis string value can be up to 512M
String string command link
, for example:
2: Hash (hash)
Redis hash field is a string type and the value of the mapping table, hash is particularly suited for storing objects.
3: List (List)
Redis list is a simple list of strings, sort insertion order. You can add an element to the head of the list (on the left) or trailing (right side) (bottom is actually a linked list)
For example:
4: Set (collection)
Redis of type String Set is an unordered collection. It is the only member of the collection, which means that the collection of duplicate data can not appear.
Set command link
, for example:
5: Zset (sorted set: an ordered collection)
-
Redis ordered set and the same collection is also a set of string type elements, and does not allow duplicate members.
-
The difference is that a double score will be associated with each type of element. It is to redis from small to large order of collection of member passing score.
-
Members of the ordered set is unique, but the score (score) it can be repeated.