Question:
Is it possible to store json Files in Amazon Web Services Redis compatible Elasticache?If possible what is the best method to accomplish the same?
Answer:
reJson is a module add-on in the Redis ecosystem. It can store JSON directly into Redis cache. However modules are not supported in AWS elastic cache due to licensing issues.
TLDR – Amazon is profiting from open source and not contributing back. https://techcrunch.com/2019/02/21/redis-labs-changes-its-open-source-license-again/
So if you like to store JSON directly, you’d need to spin up your own cluster of EC2, install Redis with reJSON.
Alternative route is to see if you can store “Hash” data type or “string” in Elastic cache based on your use cases…
In the case of going with the route of storing a JSONified string into redis as a value per key, your application would have to parse it back to JSON after it retrieves the data from Redis.
Same goes for Hash, though for the case of Hash, you can access specific fields instead of the entire JSON.
If you envision your application to add more fields in the future, but you need some fields in most cases, go with Hash. Otherwise for simplicity sake, go with String.