Dealing with large databases on Redis is quite painful so we build these utils that are based on the SCAN operation so they will not block your database. We will continue adding new operations as soon as we find it necessary. Feel free to report any bugs or contribute with new operations.
Count
Safely counts keys matching a patters on Redis.
Installation
npm install chmod +x ./count.js
Usage
./count.js [-h] [-p] [-a] [-t] [--pattern]
Options [default]
-hRedis hostname [127.0.0.1]-pRedis port [6379]-aRedis auth ['']-tRedis TLS [false]--patternGlob pattern [*]
Add Expire
Safely sets expiration for keys matching a patters on Redis. This operation will override any expiration set on the keys.
Installation
npm install chmod +x ./expire.js
Usage
./expire.js [-h] [-p] [-a] [-t] [--pattern] [--time]
Options [default]
-hRedis hostname [127.0.0.1]-pRedis port [6379]-aRedis auth ['']-tRedis TLS [false]--patternGlob pattern [*]--timeExpiration time in seconds [7776000]
Migrate
Migrates keys matching a pattern from one Redis to another. This procedure involves two scripts:
- Download keys and its values matching a pattern from origin Redis.
- Upload keys to destination Redis
Be aware that this procedure will remove all expires.
Installation
npm install chmod +x ./download.js chmod +x ./upload.js
download.js usage
./download.js [-h] [-p] [-a] [-t] [--pattern] [--filename]
download.js options [default]
-horigin Redis hostname [127.0.0.1]-porigin Redis port [6379]-aorigin Redis auth ['']-torigin Redis TLS [false]--patternGlob pattern [*]--filenameFilename of the json [dump.json]
upload.js usage
./upload.js [-h] [-p] [-a] [-t] [--filename]
upload.js options [default]
-hdestination Redis hostname [127.0.0.1]-pdestination Redis port [6379]-adestination Redis auth ['']-tdestination Redis TLS [false]--filenameFilename of the json [dump.json]
Oldest key
Get the oldest idle time.
Installation
npm install chmod +x ./oldest.js
Usage
./oldest.js [-h] [-p] [-a] [-t]
Options [default]
-hRedis hostname [127.0.0.1]-pRedis port [6379]-aRedis auth ['']-tRedis TLS [false]