#bind 127.0.0.1 #注释掉这一句,使redis可以外部访问
port 6379 #默认端口,可以改成别的端口
protected-mode yes #修改为yes,开启保护模式,默认是yes
#daemonize no #这一句是注释的,windows版本不支持,默认是no
requirepass 123456 #密码
appendonly yes
C:\Program Files\Redis>redis-cli.exe -h 127.0.0.1 -p 6379
127.0.0.1:6379> ping
PONG
127.0.0.1:6379> set key1 v1
OK
127.0.0.1:6379> get key1
"v1"
127.0.0.1:6379> get key
(nil)
127.0.0.1:6379> set name "wbq"
OK
127.0.0.1:6379> get name
"wbq"
127.0.0.1:6379> set name "whp"
OK
127.0.0.1:6379> get name
"whp"
127.0.0.1:6379> del name
(integer) 1
127.0.0.1:6379> hmset name field1 "wbq" field2 "whp"
OK
127.0.0.1:6379> hget name field1
"wbq"
127.0.0.1:6379> hget name field2
"whp"
127.0.0.1:6379> lpush alist redis
(integer) 1
127.0.0.1:6379> lpush alist db2
(integer) 2
127.0.0.1:6379> lpush alist mysql
(integer) 3
127.0.0.1:6379> lrange alist 2
1) "mysql"
2) "db2"
3) "redis"
127.0.0.1:6379> lrange alist 1
1) "mysql"
2) "db2"
127.0.0.1:6379> sadd aset set1
(integer) 1
127.0.0.1:6379> sadd aset set2
(error) MISCONF Redis is configured to save RDB snapshots, but it is currently not able to persist on disk. Commands that may modify the data set are disabled, because this instance is configured to report errors during writes if RDB snapshotting fails (stop-writes-on-bgsave-error option). Please check the Redis logs for details about the RDB error.
127.0.0.1:6379> sadd aset set3
(error) MISCONF Redis is configured to save RDB snapshots, but it is currently not able to persist on disk. Commands that may modify the data set are disabled, because this instance is configured to report errors during writes if RDB snapshotting fails (stop-writes-on-bgsave-error option). Please check the Redis logs for details about the RDB error.
127.0.0.1:6379> sadd aset set3 [member ...]
127.0.0.1:6379> config set stop-writes-on-bgsave-error no
OK
127.0.0.1:6379> sadd aset set2
(integer) 1
127.0.0.1:6379> sadd aset set3
(integer) 1
127.0.0.1:6379> sadd aset set4
(integer) 1
127.0.0.1:6379> sadd aset set2
(integer)
127.0.0.1:6379> smembers aset
1) "set4"
2) "set3"
3) "set1"
4) "set2"
127.0.0.1:6379>
[34752] 27 Apr 11:50:16.328 # fork operation complete
[34752] 27 Apr 11:50:16.340 # Background saving error
[34752] 27 Apr 11:50:22.046 * 1 changes in 900 seconds. Saving...
[34752] 27 Apr 11:50:22.115 * Background saving started by pid 7944
[7944] 27 Apr 11:50:22.251 # Failed opening the RDB file dump.rdb (in server root dir C:\Program Files\Redis) for saving: 数据。
[7944] 27 Apr 11:50:22.253 # rdbSave failed in qfork: Permission denied
[34752] 27 Apr 11:50:22.325 # fork operation complete
[34752] 27 Apr 11:50:22.338 # Background saving error
[34752] 27 Apr 11:50:28.046 * 1 changes in 900 seconds. Saving...
[34752] 27 Apr 11:50:28.112 * Background saving started by pid 20004
[20004] 27 Apr 11:50:28.229 # Failed opening the RDB file dump.rdb (in server root dir C:\Program Files\Redis) for saving: 数据。
[20004] 27 Apr 11:50:28.231 # rdbSave failed in qfork: Permission denied
[34752] 27 Apr 11:50:28.326 # fork operation complete
[34752] 27 Apr 11:50:28.343 # Background saving error
[34752] 27 Apr 11:50:34.060 * 1 changes in 900 seconds. Saving...
[34752] 27 Apr 11:50:34.126 * Background saving started by pid 32840
[34752] 27 Apr 11:50:34.339 # fork operation complete
[34752] 27 Apr 11:50:34.383 * Background saving terminated with success
127.0.0.1:6379> zadd asortedset redis
(integer) 1
127.0.0.1:6379> zadd asortedset 1 db2
(integer) 1
127.0.0.1:6379> zadd asortedset sqlserver
(integer) 1
127.0.0.1:6379> zrangebyscore asortedset 5
1) "redis"
2) "sqlserver"
3) "db2"
127.0.0.1:6379>
127.0.0.1:6379> select 1
OK
127.0.0.1:6379[1]> get key1
(nil)
127.0.0.1:6379[1]> zrangebyscore asortedset 5
(empty list or set)
127.0.0.1:6379[1]> select
OK
127.0.0.1:6379> zrangebyscore asortedset 5
1) "redis"
2) "sqlserver"
3) "db2"
127.0.0.1:6379> select 2
OK
127.0.0.1:6379[2]> zrangebyscore asortedset 5
(empty list or set)
127.0.0.1:6379[2]>
127.0.0.1:6379> del userdaydata:username:user1:data
(integer) 1
127.0.0.1:6379> rpush userdaydata:username:user1:data 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
(integer) 24
127.0.0.1:6379> lrange userdaydata:username:user1:data 23
1) "0"
2) "1"
3) "2"
4) "3"
5) "4"
6) "5"
7) "6"
8) "7"
9) "8"
10) "9"
11) "10"
12) "11"
13) "12"
14) "13"
15) "14"
16) "15"
17) "16"
18) "17"
19) "18"
20) "19"
21) "20"
22) "21"
23) "22"
24) "23"
127.0.0.1:6379> lpop userdaydata:username:user1:data
"0"
127.0.0.1:6379> lrange userdaydata:username:user1:data 23
1) "1"
2) "2"
3) "3"
4) "4"
5) "5"
6) "6"
7) "7"
8) "8"
9) "9"
10) "10"
11) "11"
12) "12"
13) "13"
14) "14"
15) "15"
16) "16"
17) "17"
18) "18"
19) "19"
20) "20"
21) "21"
22) "22"
23) "23"
127.0.0.1:6379> rpush userdaydata:username:user1:data
(integer) 24
127.0.0.1:6379> lrange userdaydata:username:user1:data 23
1) "1"
2) "2"
3) "3"
4) "4"
5) "5"
6) "6"
7) "7"
8) "8"
9) "9"
10) "10"
11) "11"
12) "12"
13) "13"
14) "14"
15) "15"
16) "16"
17) "17"
18) "18"
19) "19"
20) "20"
21) "21"
22) "22"
23) "23"
24) "0"
127.0.0.1:6379> lpop userdaydata:username:user1:data
"1"
127.0.0.1:6379> lrange userdaydata:username:user1:data 23
1) "2"
2) "3"
3) "4"
4) "5"
5) "6"
6) "7"
7) "8"
8) "9"
9) "10"
10) "11"
11) "12"
12) "13"
13) "14"
14) "15"
15) "16"
16) "17"
17) "18"
18) "19"
19) "20"
20) "21"
21) "22"
22) "23"
23) "0"
127.0.0.1:6379> rpush userdaydata:username:user1:data 1
(integer) 24
127.0.0.1:6379> lrange userdaydata:username:user1:data 23
1) "2"
2) "3"
3) "4"
4) "5"
5) "6"
6) "7"
7) "8"
8) "9"
9) "10"
10) "11"
11) "12"
12) "13"
13) "14"
14) "15"
15) "16"
16) "17"
17) "18"
18) "19"
19) "20"
20) "21"
21) "22"
22) "23"
23) "0"
24) "1"
127.0.0.1:6379>
参考:https://blog.csdn.net/qq_45047809/article/details/112529734https://www.runoob.com/redis/redis-tutorial.html