redis 清理缓存

----windos

方法1,重启redis也能请缓存。

方法2,清缓存前确保redis-server.exe进程已经启动,然后打开redis-cli.exe,跳出的CMD里面输入flushall,显示OK就可以了。

flushall:清空整个redis 服务器的数据(删除所有数据库的所有 key )。

flushdb:清空当前数据库中的所有 key。

方法3,清空指定Key,例如:

del key1

del key2

方法4,使用JAVA清理

public static void flushAll(){

Jedis jedis = new Jedis("127.0.0.1",5050);

jedis.connect();

jedis.flushAll();

jedis.disconnect();

}

方法5,使用脚本批量清空所有缓存,下面以Spring实现Redis批量清空缓存为例:

@Autowired

private StringRedisTemplate stringRedisTemplate;

public void deleteKeys(){

Set keys = stringRedisTemplate.keys("*");

stringRedisTemplate.delete(keys);

}

方法6,还有定时清理,具体百度

----linux

1、先确保redis进程存活

ps -ef|grep redis

2、执行./redis-cli或者./redis-cli -h 127.0.0.1 -p 6379

root@slave bin\]# ./redis-cli 3、执行:dbsize命令 4、执行:flushall命令 5、使用keys \* 进行验证是否为空 6、执行:exit ![](https://i-blog.csdnimg.cn/blog_migrate/346c22aae0b8f5a47841432ad619b5fc.png) 参考: [linux下清理redis缓存 - 知乎](https://zhuanlan.zhihu.com/p/635376304 "linux下清理redis缓存 - 知乎") ---------------------20231007 补充 如果是不能直连,需要通过redis -cli连接, redis-cli -h 127.0.0.1-p 22 -a "password" --bigkeys 默认端口是22 连接上后,执行flushall 也行,或者 查看大字段情况 --bigkeys

相关推荐
zlpzpl4 分钟前
MySQL 的 INSERT(插入数据)详解
android·数据库·mysql
摩拜芯城IC29 分钟前
8通道TDM分组传输IC DS34S108GN芯片参数资料 E1/T1分组化芯片
数据库
u***357434 分钟前
MySQL ——数据的增删改查
数据库·mysql
zjttsh1 小时前
MySQL 数据库基础
数据库·mysql·oracle
万邦科技Lafite2 小时前
淘宝店铺所有商品API接口实战指南
java·数据库·mysql
dinga198510262 小时前
linux上redis升级
linux·运维·redis
mqffc2 小时前
Mysql 驱动程序
数据库·mysql
wl85112 小时前
SAP-CPI-SF问题收集009 user id is either invalid or purged
数据库
c***03233 小时前
linux centos8 安装redis 卸载redis
linux·运维·redis
摩拜芯城IC3 小时前
RS -485/RS -422 全双工收发器 ISO3086TDW芯片参数资料 驱动集成 IC
数据库