Is it possible to easily set specific value from a file using interactive redis-cli
?
I'd like to achieve same result as with following Python snippet:
with open("some.jpg") as f:
image_binary = f.read()
rd.hset("some_key", "image_binary", image_binary)
During fetching the records from database,first check whether the key present(primary key i.e id) in redis,if "yes" get data directly from redis,otherwise hit the database for data. Suppose database tables are posts,comments.
To start Redis client, open the terminal and type the command redis-cli. This will connect to your local server and now you can run any command.
The Redis configuration file is located at installdir/redis/etc/redis. conf.
Is it possible to easily set specific value from a file using interactive redis-cli?
Since -x
reads the last argument from STDIN
, what about:
redis-cli -x HSET some_key image_binary <some.jpg
You can then easily retrieve the file as follow:
redis-cli --raw HGET some_key image_binary > img.jpg
Note that there is an extra \n
character at the end.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With