redis基础使用

时间:2023-03-09 15:40:36
redis基础使用

redis分linux,window两个版本分支.

redis在window下的使用先下载相关包.下载地址:https://github.com/MSOpenTech/redis/releases

下载完成执行 redis-server.exe  以默认配置启动.

如自定义配置(配置改动在 redis.windows.conf 文件里修改), 应执行 : redis-server.exe redis.windows.conf

查看实时日志:

如需查看日志 , 在上述服务端启动的情况下 cmd命令执行客户端 :  redis-cli.exe

输入 monitor 即可显示实时日志

--------常用命令-----------

get key_name (获取key_name的值)
randomkey (随机获取一个key)
keys * (列出所有key)
TTL key_name (获取key_name到期的剩余秒数)

client list (获取所有连接的客户端)
info (显示服务器的信息)
monitor (显示实时日志)

config get timeout(查看超时,如果连接没有使用,就会根据timeout的值关闭连接) -- 对应了配置文件中的timeout值

config set timeout 30 -- (Close the connection after a client is idle for 30 seconds)

------------------------------

PS: 如果不想敲命令 ,可使用客户端Redis Desktop Manager .下载地址 :https://redisdesktop.com/download