Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Redis to temporary caching files

I would like to temporary cache uploaded files in Redis. I know it is utilizing a lot of memory, but I think it is the best way to have a really low latency for a temporary amount of time.

How do I store files in Redis? Do I somehow convert them into binary and store them and decode them when I need them?

like image 538
vancua Avatar asked Feb 18 '26 21:02

vancua


1 Answers

Strings in Redis are binary safe, which means you could store binary files without any problem (https://redis.io/topics/data-types#strings).

The way you will do this depends on the language and frameworks you are using, but, generally speaking, one way to accomplish this is just storing in Redis the file content as base64.

Hope it helps.

like image 191
bruno.zambiazi Avatar answered Feb 21 '26 13:02

bruno.zambiazi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!