Redis-cli and value from file

Is it possible to easily set a specific value from a file using interactive redis-cli ?

I would like to achieve the same result as using the following Python snippet:

 with open("some.jpg") as f: image_binary = f.read() rd.hset("some_key", "image_binary", image_binary) 
+6
source share
1 answer

Is it possible to easily set a specific value from a file using interactive redis-cli?

Since -x reads the last argument from STDIN , how about:

 redis-cli -x HSET some_key image_binary <some.jpg 

Then you can easily get the file as follows:

 redis-cli --raw HGET some_key image_binary > img.jpg 

Note that there is an extra \n character at the end.

+11
source

Source: https://habr.com/ru/post/957521/


All Articles