MAC下用redis图形客户端查数据库太不顺畅,刷新也不方便,偶尔说不定还来一次假死
最新验证一个东西,数据并没有做持久化,不到一分钟就会清除,如果redis进行了更新,客户端刷新等半天说不定刷新好了数据都消失了,十分不便,因此还是用连接redis-server然后进行CLI操作比较方便
首先连上redis,这几个参数即可
lihui@2018 ~ redis-cli --help redis-cli 4.0.10 Usage: redis-cli [OPTIONS] [cmd [arg [arg ...]]] -h Server hostname (default: 127.0.0.1). -p Server port (default: 6379). -s Server socket (overrides hostname and port). -a Password to use when connecting to the server.
要注意的是,-a密码要带引号
如果存储的是最简单的STRING:Value,通过get可以直接得到value
通过help可以查看相关参数
redis-cli> help get GET key summary: Get the value of a key since: 1.0.0 group: string redis-cli> redis-cli> get lbsmesh:data:customer_track:950300179:9 "\x01\x00com.caocao.mesh.server.manage.bo.CustomerTrackB\xcf\x04bi\xfacustomerN\xefla\xf4ln\xe7\x02\x01\x12\x00\x06\x01\xa6\xb8\xa3\x8a\a\x00\t\x01@>5v}'\xd2~\x00\t\x01@^\x0e\x00\x8d\x15\x9e(\x00"
直接可以得到value
如果在客户端上看到有多层级目录,没关系,命名空间名称最后都会带到key里面
比如set数据
redis-cli> help SMEMBERS SMEMBERS key summary: Get all the members in a set since: 1.0.0 group: set redis-cli> redis-cli> SMEMBERS featureSetKey 1) "userTime2" 2) "model" 3) "useTime4" 4) "useTime3" 5) "limitedTimes"
还有一个zset类型,在KV的基础上,加了一个score字段,按这个字段进行排序来储存
查询命令
redis-cli> help zrange ZRANGE key start stop [WITHSCORES] summary: Return a range of members in a sorted set, by index since: 1.2.0 group: sorted_set redis-cli> redis-cli> ZRANGE lbs:trace:9997816224 0 5 1) "{\"accuracy\":36.0,\"cityCode\":\"0571\",\"createTime\":1532662022739,\"direction\":75.0,\"driverNo\":\"482904\",\"height\":10.0,\"lg\":120.222249,\"lt\":30.207443,\"speed\":27.0}" 2) "{\"accuracy\":35.0,\"cityCode\":\"0571\",\"createTime\":1532662032753,\"direction\":75.0,\"driverNo\":\"482904\",\"height\":10.0,\"lg\":120.223249,\"lt\":30.208843,\"speed\":17.0}" 3) "{\"accuracy\":36.0,\"cityCode\":\"0571\",\"createTime\":1532662042751,\"direction\":75.0,\"driverNo\":\"482904\",\"height\":10.0,\"lg\":120.223449,\"lt\":30.209243,\"speed\":44.0}" 4) "{\"accuracy\":38.0,\"cityCode\":\"0571\",\"createTime\":1532662052755,\"direction\":75.0,\"driverNo\":\"482904\",\"height\":10.0,\"lg\":120.224849,\"lt\":30.210843,\"speed\":16.0}" 5) "{\"accuracy\":38.0,\"cityCode\":\"0571\",\"createTime\":1532662062753,\"direction\":75.0,\"driverNo\":\"482904\",\"height\":10.0,\"lg\":120.225649,\"lt\":30.211643,\"speed\":21.0}" 6) "{\"accuracy\":34.0,\"cityCode\":\"0571\",\"createTime\":1532662072743,\"direction\":75.0,\"driverNo\":\"482904\",\"height\":10.0,\"lg\":120.226649,\"lt\":30.212443,\"speed\":44.0}"
hash表
redis-cli> help hget HGET key field summary: Get the value of a hash field since: 2.0.0 group: hash redis-cli> HGET order_dispatch_count 50001728 "2"
详细各种数据类型的增删改查CLI操作,可以参考这里Redis CLI