1下载安装后启动客户端调试:
cd到安装路径
cd C:\Program Files\Redis
redis-cli.exe -h 127.0.0.1 -p 6379
密码修改:修改配置文件“redis.windows-service.conf
################################## SECURITY ##################
# Require clients to issue AUTH <PASSWORD> before processing any other
# commands. This might be useful in environments in which you do not trust
# others with access to the host running redis-server.
#
# This should stay commented out for backward compatibility and because most
# people do not need auth (e.g. they run their own servers).
#
# Warning: since Redis is pretty fast an outside user can try up to
# 150k passwords per second against a good box. This means that you should
# use a very strong password otherwise it will be very easy to break.
#
# requirepass foobared
requirepass 密码
修改新密码需要重启服务,认证密码
C:\Program Files\Redis>redis-server --service-start
[15236] 17 Mar 08:40:19.111 # Redis service successfully started.
C:\Program Files\Redis>redis-cli.exe -h 127.0.0.1 -p 6379
127.0.0.1:6379> keys *
(error) NOAUTH Authentication required.
127.0.0.1:6379> auth food
OK -------------认证成功
2查看所有key
查看所有key3判断 key的类型
image.png4 string 类型数据
1) 设置值set ,取值get
image.png- 修改key的名字
3)删除key
image.png4) 查看key是否存在
image.png5)设置key的过期时间,以秒计算 EXPIRE KEY Second
image.png6)以秒为单位,返回给定 key 的剩余生存时间(TTL, time to live)。
PTTL key以毫秒为单位返回 key 的剩余的过期时间
image.png5 LIST列表数据类型
6 哈希数据
6.1 HGETALL key 获取在哈希表中指定 key 的所有字段和值
image.png6.2 HSET key field value 将哈希表 key 中的字段 field 的值设为 value 。
6.3 设置哈希的过期时间
image.png image.png哈希 key 设置过期时间后,若哈希值由更改,过期时间原先设置的剩余过期时间不变。若想改变过期时间,需要重新设置。key过期后,Redis中将key自动从Redis数据库中删除。若想继续使用,可以重新创建。
网友评论