redis批量修改查询key

Published on with 0 views and 0 comments
  • 查询所有的 keys
    keys teacher_sso_username*
  • 查询 key 的 TTL
    ttl teacher_sso_username:13444444416
  • 批量修改 key 的 TTL 时间
    编写脚本 expireAll.sh
    redis-cli -h 127.0.0.1 -p 6379 -a Cg44uwsgsgsg1 expire $1 1296000
    执行命令
    redis-cli -h 127.0.0.1 -p 6379 -a Cg44uwsgsgsg1 keys "support_sso_userinfo*" | xargs -I {} ./expireAll.sh {}

脚本内容:

#!/bin/bash
redis-cli -h 127.0.0.1 -p 6379 -a Cg44uh6I96f0RPb1 expire $1  554715

第二种(批量删除缓存):

redis-cli -h 127.0.0.1 -p 6379 -a Cg44uh6I96f0RPb1 keys "student_sso_username*" |  xargs redis-cli -h 127.0.0.1 -p 6379 -a Cg44uh6I96f0RPb1 del

标题:redis批量修改查询key
作者:cuijianzhe
地址:https://cuijianzhe.github.io/articles/2021/04/03/1617425259423.html