Decided to store images in Redis, how to do it correctly? Now I do this:
$redis->set('image_path', 'here is the base64 image code');
I’m not sure this is normal.
Decided to store images in Redis, how to do it correctly? Now I do this:
$redis->set('image_path', 'here is the base64 image code');
I’m not sure this is normal.
2
Answers
It is perfectly ok to store images in Redis. Redis keys and values are both binary-safe
See Data types
You can store the image in binary instead of base64 and it will be more efficient:
You can do
$client->set('profile_picture', file_get_contents("profile.png"));
See Storing Binary Data in Redis
Here is my simple example of storing image file into Redis Database and retrieve them as well