Redis管理工具-RedisWebManager
2018-12-22 本文已影响0人
Willis1
关注及时更新请查看我的博客:Redis管理工具-RedisWebManager
这是我自己写的一个Redis管理工具,自动decode Redis缓存中的json串为数组,自动unserialize Redis缓存中的序列化串为对象,这样可以非常直观的查看数据(当然这两个功能目前仅限php),这可能是目前php版本的最好用的redis管理工具了,虽然目前还无法添加和修改redis内容,只能查看和删除,但调试项目的时候一般都是查看和删除比较多,如果要修改一个值,你把它删除了程序重新从数据库取也是一样的,所以个人认为添加和修改用的并不多,暂时就没做,以后有时间,有需要的话可能会加上。
首页预览:![](https://img.haomeiwen.com/i6986754/e6ea6e190658abad.jpg)
![](https://img.haomeiwen.com/i6986754/4711acd3a513f8cb.jpg)
![](https://img.haomeiwen.com/i6986754/56a51b2a570a66f9.jpg)
![](https://img.haomeiwen.com/i6986754/a2cc226c4545acfd.jpg)
从上面几张图的内容可以看到,RedisWebManager是直接显示查出的值的原始内容(如数组或对象),而不是显示json化后的json字符串,或者序列化后的字符串,这是本工具最大的优势,也是我写本工具的最重要的原因,特别项目测试时,有时候需要查看缓存数据,这个功能会非常方便(但反序列化目前仅针对php有效,未测试过其他语言的序列化与反序列化)!
功能
- 查看redis Key列表
- 预览某个key的值(弹窗/行内/新页面方式)
- 以预览数组的方式预览json,以预览对象的方式预览序列化后的对象(这是我写这个工具的最重要的原因)
- 使用key前缀后缀搜索
- 删除单个key & 批量删除key
- 选择显示某个db的数据
- 清空当前db或者清空所有db
- 查看Redis服务器相当信息
安装
git clone https://github.com/xiebruce/RedisWebManager.git
Redis 配置
配置文件在(在本地自动加载redis_local.php文件,在线上自动加载 redis.php文件):
RedisWebManager/config/redis.php
RedisWebManager/config/redis_local.php
配置清空db的密码 & 配置快速查询的Key
RedisWebManager/config/params.php
RedisWebManager/config/params_local.php
登录账号密码配置
RedisWebManager/models/User.php
如图,username为账号,password为密码,只需要修改username和password对应的值即可,如果你想要多个账号,那就复制多份,注意把key和id值改一下,这个就相当于数据库查出来的一条数据,key和id就是数据库的自增id,因为我们不配置数据库,所以直接写死在这里。
![](https://img.haomeiwen.com/i6986754/f5c7fb894f7a0ee2.jpg)
设置权限
sudo chmod -R 777 /path/to/RedisWebManager/runtime
sudo chmod -R 777 /path/to/RedisWebManager/web/assets
Nginx 配置
建议添加nginx密码认证,这样就算别人知道地址也无法进入:Nginx添加密码认证
server {
charset utf-8;
client_max_body_size 128M;
listen 80; ## listen for ipv4
#listen [::]:80 default_server ipv6only=on; ## listen for ipv6
server_name redis.mydomain.com;
root /data/wwwroot/RedisWebManager/web;
index index.php;
access_log /path/to/RedisWebManager/log/access.log;
error_log /path/to/RedisWebManager/log/error.log;
location / {
# Redirect everything that isn't a real file to index.php
try_files $uri $uri/ /index.php$is_args$args;
}
# uncomment to avoid processing of calls to non-existing static files by Yii
#location ~ \.(js|css|png|jpg|gif|swf|ico|pdf|mov|fla|zip|rar)$ {
# try_files $uri =404;
#}
#error_page 404 /404.html;
# deny accessing php files for the /assets directory
location ~ ^/assets/.*\.php$ {
deny all;
}
location ~ \.php$ {
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass 127.0.0.1:9000;
#fastcgi_pass unix:/var/run/php5-fpm.sock;
try_files $uri =404;
}
location ~* /\. {
deny all;
}
}
注意事项
由于redis的特殊,分页其实并不太准确,你刷新一次它的数据都不一样,所以上一页下一页并不是太重要,要查数据直接查就行,靠分页肉眼看数据会比较累。
更新日志
2018-12-19 v0.2
- 添加行内预览值方式
- 添加显示key的ttl(生存时间)
- 弹窗修改为boostrap的模态框,而不是之前简单的js alert。
- 修改在新页面查看值的页面布局
- 彩色显示数组和对象。
- 修复很多bug。
2018-12-14 v0.1
- 这是一个redis web管理工具,你可以用它搜索、删除、批量删除redis key,预览key的值,清空当前db,当空所有db。