1、参考官网资料
redis官网中文文档:http://www.redis.cn/documentation.html
Redis
: REmote DIctionary Server 远程字典服务器。key-value键值对内存数据库。
2、连接操作
连接远程:redis-cli -h host -p port -a password
- 【示例】
[lxx@lsyPro src ]$ redis-cli -h yd-cash01.redis.cache.chinacloudapi.cn -p 6379 -a sglsdfkjksdfkkfagdgafs124f=
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
yd-cash01.redis.cache.chinacloudapi.cn:6379>
3、redis基本数据结构
-
string
: 字符串 -
hash
:主要用于存储对象,值就是key=value形式 -
list
:列表 -
set
:集合类型 string无序列表,实现方式是按照哈希,去重复 -
zset
:有序集合,去重复set
【样例】:
- 字符串:
[127.0.0.1:6379> set stringkey 1234kfdf
OK
[127.0.0.1:6379> get stringkey
"1234kfdf"
- hash 散列

- list 列表
127.0.0.1:6379> LPUSH books english chinese garmin
(integer) 3
127.0.0.1:6379> llen books
(integer) 3
127.0.0.1:6379> lrange books 0 10
1) "garmin"
2) "chinese"
3) "english"
127.0.0.1:6379>

- set 集合
[127.0.0.1:6379> sadd scollection lights cup tree desk

- 有序集合
[127.0.0.1:6379[2]> zadd zsetLog 20 sdd
(integer) 1
[127.0.0.1:6379[2]> zadd zsetLog 10 java
(integer) 1

4、 命令单元
- redis 操作基本命令格式:COMMAND KEY_NAME
注
:未完待续
5、redis特性(优点)
redis 数据库中的数据存于内存,内存读写速度远快于硬盘。同时,Redis可以将数据持久化,异步写入磁盘,不影响服务提供
6、名词解释
- TTL:Time To Live 键的生存时间。
7、redis约束
- 版本约束:5.0.5 第二位小数
0
为偶数表示稳定版。 奇数表示非稳定版
网友评论