windows批量删除指定前缀key

直接上代码:
del_keys_by_prefix.bat

@echo off
echo 调用格式:[redis地址] [redis密码] [redis库号] [待删除的key前缀带*]
set keysfile=redis-cached-keys.txt
redis-cli -h %1 -a %2 -n %3  keys %4 > %keysfile%
FOR /F %%i in (%keysfile%) DO (redis-cli -h %1 -a %2 -n %3  del %%i)
DEL /F /Q %keysfile%
echo 操作完成

参考:https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/details/116998941?utm_medium=distribute.pc_aggpage_search_result.none-task-blog-2aggregatepagefirst_rank_ecpm_v1~rank_v31_ecpm-5-116998941-null-null.pc_agg_new_rank&utm_term=windows%E4%B8%8Bredis%E5%88%A0%E9%99%A4%E6%89%80%E6%9C%89%E6%8C%87%E5%AE%9A%E5%89%8D%E7%BC%80%E7%9A%84key&spm=1000.2123.3001.4430

你可能感兴趣的:(Windows,redis,数据库,database)