Redis 键(key)
//设置 key 为name ,value 为can
set name can
//获取键 的 值
get name
Redis 哈希(Hash)
//设置 哈希(Hash)
//cankey 是key ,后面都是cankey的 value
HMSET cankey name "redis tutorial" description "redis basic commands for caching" likes 20 visitors 23000
//获得哈希值
HGETALL cankey
效果如下:
列表 List
// list push
LPUSH lkykey vb
LPUSH lkykey mysql
//list range 列表范围区间
LRANGE lkykey 0 10
集合(set)
SADD can redis
SADD can java
SADD can sql
SMEMBERS can
效果如下:
有序集合 (sorted set)
ZADD cankeyz 1 redis
ZADD cankeyz 2 java
ZADD cankeyz 3 php
ZADD cankeyz 4 mysql
ZADD cankeyz 5 nodejs
ZRANGE cankey 0 10 WITHSCORES