栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

redis的基本命令

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

redis的基本命令

① keys *

查看当前库的所有key

② set test_key test_value

创建一个键值对 ,test_key为键,test_value为值

③ get test_key

返回test_key键的值

④ exists test_key

判断这个键是否存在

⑤ move test_key 1

把test_key这个键值对移动到第二个数据库,Redis默认有16个数据库

⑥ expire test_key 10

给test_key这个键设置过期时间 10s

⑦ ttl test_key

查看这个兼职对的过期剩余时间

⑧ type test_key

查看test_key的类型

⑨ append test_key "hello word"

追加命令,给test_key追加一个字符串

⑩ strlen test_key

获取键 = test_key 字符串的长度

11、 步长
127.0.0.1:6379> set read_num 0  ##创建一个键值对
OK
127.0.0.1:6379> type read_num  
string
127.0.0.1:6379> 
127.0.0.1:6379> 
127.0.0.1:6379> incr read_num  ##键值对加1
(integer) 1
127.0.0.1:6379> incrby read_num 10 ##加10
127.0.0.1:6379> get read_num  
"1"
127.0.0.1:6379> decr read_num  ##减1
(integer) 12
127.0.0.1:6379> decrby read_num 5 ##减5

学习redis的命令可以直接到redis官网上面查看

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/831787.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号