Redis-cli

Redis是什么

内存中的数据结KV构存储系统,常用作于高速缓存。

5种Redis数据结构的直观感受

这里写图片描述

对key的操作

#模糊查询
127.0.0.1:6379> keys *
1) "ztan"
2) "ztan_key"
3) "website"
4) "app::users::click"
5) "redis-test"
6) "testkey"
7) "ztan tan"
8) "province"
127.0.0.1:6379> keys z*
1) "ztan"
2) "ztan_key"
3) "ztan tan"
#查询某key存在与否
127.0.0.1:6379> exists province
(integer) 1
127.0.0.1:6379> exists province2
(integer) 0
127.0.0.1:6379> 
#增加key
127.0.0.1:6379> APPEND test testvalue
(integer) 9
127.0.0.1:6379> keys *
1) "test"
2) "ztan_key"
3) "redis-test"
4) "testkey"
5) "ztan tan"
6) "ztan"
7) "website"
8) "app::users::click"
9) "province"
#删除key
127.0.0.1:6379> del test
(integer) 1
127.0.0.1:6379> keys *
1) "ztan_key"
2) "redis-test"
3) "testkey"
4) "ztan tan"
5) "ztan"
6) "website"
7) "app::users::click"
8) "province"
127.0.0.1:6379> 

对value(字符串)的操作

#查看key对应的value的类型
127.0.0.1:6379> type ztan
string
#查看key对应的value的值
127.0.0.1:6379> get ztan
"test"
127.0.0.1:6379> 

对value(哈希)的操作

#查看key对应的value的类型
127.0.0.1:6379> type province
hash
#key对应的value是哈希,其实又是一个kv键值对,所以给定两个参数
127.0.0.1:6379> hget province ZheJiang
"2991091"
#返回key对应value里边的多个key对应的值
127.0.0.1:6379> hmget province ZheJiang JiangSu
1) "2991091"
2) "3026906"
127.0.0.1:6379> 
#返回key对应的value里边的所有key
127.0.0.1:6379> hkeys province
 1) "other"
 2) "HeBei"
--后略---
#返回key对应的value里边的所有value
127.0.0.1:6379> hvals province
 1) "0"
 2) "2918391"
--后略---
#返回key对应的value里边的所有key和所有value
127.0.0.1:6379> hgetall province
 1) "other"
 2) "0"
 3) "HeBei"
 4) "2918391"
--后略---

参照资料

http://www.redis.cn/topics/data-types-intro.html
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值