Redis的LogLevel有4个级别
1、debug 2、verbose 3、notice 4、warning
但是默认是:loglevel notice
第一步先启动服务端:
redis-server redis.windows.conf
第二步启动客户端:
redis-cli.exe -h localhost -p 6379
查看客户端是否连通:
localhost:6379> ping
PONG
出现PONG即为连通
设置并查看日志级别:
CONFIG set loglevel debug
OK
localhost:6379> CONFIG GET loglevel
- "loglevel"
- "debug"
第三步设置密码并登陆:
localhost:6379> config set requirepass 123456
OK
localhost:6379> AUTH 123456
OK
查看密码:
localhost:6379> CONFIG GET requirepass - "requirepass"
- "123456"
// 设置获取 string
localhost:6379> set ysx yanshixian
OK
localhost:6379> get ysx
"yanshixian"
// 存储 hash 类型,适合存储对象。
localhost:6379> hmset stu0 sid 02142010 score 99 name ysx
OK
localhost:6379> hmset stu1 sid 02142011 score 100 name yanshixian
OK
localhost:6379> hgetall stu0
1) "sid"
2) "02142010"
3) "score"
4) "99"
5) "name"
6) "ysx"
localhost:6379> hgetall stu1 sid
(error) ERR wrong number of arguments for 'hgetall' command
localhost:6379> hget stu1 sid
"02142011"
//3. lists:(1)重复有序,返回下标索引。(2)redis的list基于链表,查询慢,插⼊删除快。
//左侧插⼊
localhost:6379> lpush subject java
(integer) 1
localhost:6379> lpush subject html5
(integer) 2
localhost:6379> lpush subject python
(integer) 3
localhost:6379> lrange subject 1 100
1) "html5"
2) "java"
localhost:6379> lrange subject start stop
//右侧插⼊
localhost:6379> rpush bike hello
(integer) 1
localhost:6379> rpush bike ofo
(integer) 2
localhost:6379> rpush bike blue
(integer) 3
localhost:6379> lrange bike 0 100
1) "hello"
2) "ofo"
3) "blue"
//4. set ⽆序集合,不重复,返回受影响⾏数。
localhost:6379> sadd week monday
(integer) 1
localhost:6379> sadd week WenDay
(integer) 1
localhost:6379> sadd week ysx
(integer) 1
localhost:6379> smembers week
1) "monday"
2) "WenDay"
3) "ysx"
//5. zset 有序集合,不重复。
localhost:6379> zadd java 100 yiyi
(integer) 1
localhost:6379> zadd java 100 erer
(integer) 1
localhost:6379> zadd java 99 sansan
(integer) 1
localhost:6379> zrangebyscore java 0 3
(empty list or set)
localhost:6379> zrangebyscore java 0 99
1) "sansan"
localhost:6379> zrangebyscore java 100 100
1) "erer"
2) "yiyi"