Bulk actions

functional

Delete or expire keys by pattern with a dry-run count first, and import command files.

Bulk actions clean up many keys at once without giving up the safety of the one-key dialogs. Right-click a Redis database or a key folder in the explorer:

  • Delete Keys by Pattern… (database) or Delete Keys in Folder… (folder)
  • Set TTL by Pattern… or Set TTL in Folder… - set an expiry on every matched key, or tick Remove TTL instead to PERSIST them
  • Import Command File… (database) - run a file of Redis commands, one per line

Dry run first

Delete and TTL never write first. The dialog starts from the folder's prefix or the database's current key filter, and Count Matching Keys walks the keyspace with the same bounded SCAN the key browser uses (up to 25,000 keys), so the count changes nothing. You see how many keys match before anything can be applied, and the apply step touches only the keys the dry run listed. A bulk delete asks you to type the matched key count before its button is enabled, then runs batched UNLINK commands with a progress count and a Stop button. A TTL change runs one EXPIRE or PERSIST per key; the seconds field and the Remove TTL instead box stay editable after the count. Binary key names are kept byte-exact throughout.

SQLly
Redis bulk delete: the dry-run match count for a folder's pattern before the confirmed, batched UNLINK.
Redis bulk delete: the dry-run match count for a folder's pattern before the confirmed, batched UNLINK.

Importing a command file

Pick a UTF-8 text file with one command per line (SET, HSET, EXPIRE…; blank lines and # comments are skipped). Write binary values as quoted "\xHH" escapes. SQLly reads and parses the whole file before anything runs, and refuses a file that is not a runnable command script, naming the line: an unbalanced quote, a bad JSON line, or bytes that are not valid UTF-8. The run then attempts every line at most once, with a running count of commands processed. A failing line does not stop the import: each failure is listed with its line number, the command, and the server's error, and the summary counts what succeeded and what failed. A SELECT inside the file carries over to the lines after it.

The file runs in batches of about 200 lines, each on its own connection, so a MULTI … EXEC block is never split across two batches. If a line inside a transaction fails, the transaction is discarded: the rest of that block is skipped rather than run outside it, and the summary counts the skipped lines.

Safety review

Before an import runs, every line is checked against the same Redis command list the query editor uses. The dialog shows how many lines write, and lists by line number every destructive or server-administration command it found, such as FLUSHALL, FLUSHDB, DEL, CONFIG SET, SHUTDOWN, DEBUG, SCRIPT, MODULE and ACL. When any are present, or when the connection's safety settings would make the editor ask for confirmation, you have to type RUN ALL before the file can run.

Bulk writes and imports are disabled on read-only connections, and on a production connection while its writes are locked. The explorer items are greyed out, and the dialogs explain why while still allowing the count or file check. Unlock writes from the status-bar chip first. The lock is checked again when you confirm, so an unlock that expires while the dialog is open is honoured. If you close the dialog while a run is in progress, it stops after the batch in flight, and the partial summary goes to the status bar.