TTL, rename, copy and bulk delete
- Redis / Valkey
From a key’s value editor you can set or remove its time to live, rename it and copy it, to another database too. From the key browser you can delete every key that matches a pattern, after a dry run that counts them first.
Set a TTL
Section titled “Set a TTL”- Open the key and choose TTL….
- In Time to live, enter a number in Expire in and pick the Unit: milliseconds, seconds, minutes, hours or days.
- Choose Set TTL.
The header then shows the time left, such as 2 min. To make the key permanent again, choose
Persist (no expiry) in the same dialog.
Rename a key
Section titled “Rename a key”Choose Rename…, enter the New name and choose Rename. If a key with that name exists, the rename is refused unless you tick Replace it if a key with that name exists, and replacing it asks first. The editor then shows the key under its new name.
Copy a key
Section titled “Copy a key”Choose Copy…, enter the name in Copy to key and, outside Cluster mode, pick the target Database (the current one is marked “this one”). Tick Replace it if a key with that name exists to overwrite a key of that name. Choose Copy; the copy opens in its own editor.
Delete a key
Section titled “Delete a key”Delete in the value editor, Delete key… in the side bar tree and the Delete key in the key browser delete one key, after a confirmation.
Bulk delete with a dry run
Section titled “Bulk delete with a dry run”- In the key browser, choose Bulk delete…. The Pattern starts as the browser’s pattern; if a Key type is set, only keys of that type are deleted.
- Choose Count matching keys. This is the dry run:
SCANcounts the matching keys and nothing is deleted, for example “30 keys match session:*”. - Check the sample of matching keys the dialog lists.
- Choose Delete 30 keys. Querybara deletes them with
UNLINKin batches, with a progress bar. - The dialog reports “Deleted 30 keys”. Choose Close.
Cancel stops a count or a deletion; the dialog says how many keys were deleted before it stopped. In Cluster mode the bulk delete covers every primary. Keys the ACL user may not delete are reported as refused.
From the command line
Section titled “From the command line”querybara query runs the same commands, so you can script TTL changes:
querybara query "redis://cache.example.com:6379/0" -e 'EXPIRE session:4f2a 3600'Destructive commands such as DEL, UNLINK and RENAME ask for confirmation in a terminal, or
need --yes.
Related
Section titled “Related”Documents Querybara 0.1.1 · built frombc9f5aa