I'm evaluating redis to understand between json vs string what provides better retrieval performance. As POC I set below json in redis as both json and string values and noticed that the size of JSON value is more than String - please see attached screen shots.
json value size = 239B string value size = 136B For this POC I used redis-stack-server on my mac.
Based on what I noticed, I have three questions.
- Why size of JSON value is more than String
- Why retrieval of JSON values is slower than String
- What is the best alternate to Redis that could provide me better performance as caching layer for APIs
{key:"HbaJsv"location:339secret:"nD9pVeqZIxAIPsY"delta:6}
String values screenshot
Json values screenshot
This is a sample of the code I used.
import redis
client = redis.Redis(host='localhost', port=6677)
doc = {key:"HbaJsv"location:339secret:"nD9pVeqZIxAIPsY"delta:6}
client.json().set("some_hash1", '$', doc)
client.set("some_hash2", json.dumps(doc))