当前位置:   article > 正文

Redis批量删除key_redis 批量删除key

redis 批量删除key

批量删除db1中,所有s-开头的key

redis-cli -n 1 keys s-* | xargs redis-cli -n 1 del

分析:

-n 表示redis中的数据库编号,可选值为0到15


redis-cli 帮助文档

  1. root@superman:/data# redis-cli -h
  2. redis-cli 6.2.3
  3. Usage: redis-cli [OPTIONS] [cmd [arg [arg ...]]]
  4. -h <hostname> Server hostname (default: 127.0.0.1).
  5. -p <port> Server port (default: 6379).
  6. -s <socket> Server socket (overrides hostname and port).
  7. -a <password> Password to use when connecting to the server.
  8. You can also use the REDISCLI_AUTH environment
  9. variable to pass this password more safely
  10. (if both are used, this argument takes precedence).
  11. --user <username> Used to send ACL style 'AUTH username pass'. Needs -a.
  12. --pass <password> Alias of -a for consistency with the new --user option.
  13. --askpass Force user to input password with mask from STDIN.
  14. If this argument is used, '-a' and REDISCLI_AUTH
  15. environment variable will be ignored.
  16. -u <uri> Server URI.
  17. -r <repeat> Execute specified command N times.
  18. -i <interval> When -r is used, waits <interval> seconds per command.
  19. It is possible to specify sub-second times like -i 0.1.
  20. -n <db> Database number.
  21. -3 Start session in RESP3 protocol mode.
  22. -x Read last argument from STDIN.
  23. -d <delimiter> Delimiter between response bulks for raw formatting (default: \n).
  24. -D <delimiter> Delimiter between responses for raw formatting (default: \n).
  25. -c Enable cluster mode (follow -ASK and -MOVED redirections).
  26. -e Return exit error code when command execution fails.
  27. --tls Establish a secure TLS connection.
  28. --sni <host> Server name indication for TLS.
  29. --cacert <file> CA Certificate file to verify with.
  30. --cacertdir <dir> Directory where trusted CA certificates are stored.
  31. If neither cacert nor cacertdir are specified, the default
  32. system-wide trusted root certs configuration will apply.
  33. --insecure Allow insecure TLS connection by skipping cert validation.
  34. --cert <file> Client certificate to authenticate with.
  35. --key <file> Private key file to authenticate with.
  36. --tls-ciphers <list> Sets the list of prefered ciphers (TLSv1.2 and below)
  37. in order of preference from highest to lowest separated by colon (":").
  38. See the ciphers(1ssl) manpage for more information about the syntax of this string.
  39. --tls-ciphersuites <list> Sets the list of prefered ciphersuites (TLSv1.3)
  40. in order of preference from highest to lowest separated by colon (":").
  41. See the ciphers(1ssl) manpage for more information about the syntax of this string,
  42. and specifically for TLSv1.3 ciphersuites.
  43. --raw Use raw formatting for replies (default when STDOUT is
  44. not a tty).
  45. --no-raw Force formatted output even when STDOUT is not a tty.
  46. --quoted-input Force input to be handled as quoted strings.
  47. --csv Output in CSV format.
  48. --show-pushes <yn> Whether to print RESP3 PUSH messages. Enabled by default when
  49. STDOUT is a tty but can be overriden with --show-pushes no.
  50. --stat Print rolling stats about server: mem, clients, ...
  51. --latency Enter a special mode continuously sampling latency.
  52. If you use this mode in an interactive session it runs
  53. forever displaying real-time stats. Otherwise if --raw or
  54. --csv is specified, or if you redirect the output to a non
  55. TTY, it samples the latency for 1 second (you can use
  56. -i to change the interval), then produces a single output
  57. and exits.
  58. --latency-history Like --latency but tracking latency changes over time.
  59. Default time interval is 15 sec. Change it using -i.
  60. --latency-dist Shows latency as a spectrum, requires xterm 256 colors.
  61. Default time interval is 1 sec. Change it using -i.
  62. --lru-test <keys> Simulate a cache workload with an 80-20 distribution.
  63. --replica Simulate a replica showing commands received from the master.
  64. --rdb <filename> Transfer an RDB dump from remote server to local file.
  65. --pipe Transfer raw Redis protocol from stdin to server.
  66. --pipe-timeout <n> In --pipe mode, abort with error if after sending all data.
  67. no reply is received within <n> seconds.
  68. Default timeout: 30. Use 0 to wait forever.
  69. --bigkeys Sample Redis keys looking for keys with many elements (complexity).
  70. --memkeys Sample Redis keys looking for keys consuming a lot of memory.
  71. --memkeys-samples <n> Sample Redis keys looking for keys consuming a lot of memory.
  72. And define number of key elements to sample
  73. --hotkeys Sample Redis keys looking for hot keys.
  74. only works when maxmemory-policy is *lfu.
  75. --scan List all keys using the SCAN command.
  76. --pattern <pat> Keys pattern when using the --scan, --bigkeys or --hotkeys
  77. options (default: *).
  78. --quoted-pattern <pat> Same as --pattern, but the specified string can be
  79. quoted, in order to pass an otherwise non binary-safe string.
  80. --intrinsic-latency <sec> Run a test to measure intrinsic system latency.
  81. The test will run for the specified amount of seconds.
  82. --eval <file> Send an EVAL command using the Lua script at <file>.
  83. --ldb Used with --eval enable the Redis Lua debugger.
  84. --ldb-sync-mode Like --ldb but uses the synchronous Lua debugger, in
  85. this mode the server is blocked and script changes are
  86. not rolled back from the server memory.
  87. --cluster <command> [args...] [opts...]
  88. Cluster Manager command and arguments (see below).
  89. --verbose Verbose mode.
  90. --no-auth-warning Don't show warning message when using password on command
  91. line interface.
  92. --help Output this help and exit.
  93. --version Output version and exit.
  94. Cluster Manager Commands:
  95. Use --cluster help to list all available cluster manager commands.
  96. Examples:
  97. cat /etc/passwd | redis-cli -x set mypasswd
  98. redis-cli get mypasswd
  99. redis-cli -r 100 lpush mylist x
  100. redis-cli -r 100 -i 1 info | grep used_memory_human:
  101. redis-cli --quoted-input set '"null-\x00-separated"' value
  102. redis-cli --eval myscript.lua key1 key2 , arg1 arg2 arg3
  103. redis-cli --scan --pattern '*:12345*'
  104. (Note: when using --eval the comma separates KEYS[] from ARGV[] items)
  105. When no command is given, redis-cli starts in interactive mode.
  106. Type "help" in interactive mode for information on available commands
  107. and settings.

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家自动化/article/detail/794087
推荐阅读
相关标签
  

闽ICP备14008679号