Monday, November 29, 2021

Save redis key value to file

Some of my redis key values are very large so it's easier for me to query for one key's value and view it in a file.

Environment:
CentOS Linux release 7.3.1611 (Core)
redis server 3.2.12
redis-cli 3.2.12

If I have a key named "CST_9527d72b05eb713c20465d6bc5022775bbe3a4ffb99b261a8231e967fe1585ce" enter in either command to save the key's value to cst.txt

redis-cli --scan --pattern "CST_9527d72b05eb713c20465d6bc5022775bbe3a4ffb99b261a8231e967fe1585ce" | xargs redis-cli mget > cst.txt
echo 'GET CST_9527d72b05eb713c20465d6bc5022775bbe3a4ffb99b261a8231e967fe1585ce' | redis-cli > cst.txt

Helpful Article:

https://stackoverflow.com/questions/44826691/how-to-get-value-by-redis-cli-keys

No comments:

Post a Comment

I appreciate your time in leaving a comment!