设为首页 加入收藏

TOP

脚本批量执行Redis命令
2019-09-20 11:46:17 】 浏览:48
Tags:脚本 批量 执行 Redis 命令

1、将命令写在文件中

数据量比较大的话,建议用程序去生成文件。例如:

List<String> planIdList = planDao.findAll().parallelStream().map(PlanModel::getId).map(String::valueOf).collect(Collectors.toList()); BufferedWriter br = new BufferedWriter(new OutputStreamWriter(new FileOutputStream("/Users/chengjiansheng/Desktop/command.txt"))); for (String planId : planIdList) { br.write("SADD PLAN_UNSYNC_S " + planId + "\r\n"); } br.flush(); br.close();

生成的文件可能是这样的:

接下来,命令行执行

cat command.txt | redis-cli -h 127.0.0.1 -p 6379 -a 123456 --pipe

这个例子比较简单,可以这么做,如果命令比较多的话可以写成shell脚本

2、grep命令

grep "NullPointerException" access.log | wc -l grep "com\.cjs\.babyplan\.controller\.QuestionController.*118795924" access.2019-09-17.log

 

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇在SQL Server数据库中执行存储过.. 下一篇[20190918]shrink space与ORA-081..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目