1
我想将对象的集合存储在缓存中。在缓存中存储对象集合的方法或策略
{
"name": "Dep1",
"employees": [{
"id": 1,
"name": "emp1",
"profilePic": "http://test.com/img1.png"
}, {
"id": 2,
"name": "emp2",
"profilePic": "http://test.com/img2.png"
}, {
"id": 3,
"name": "emp3",
"profilePic": "http://test.com/img3.png"
}, {
"id": 4,
"name": "emp4",
"profilePic": "http://test.com/img4.png"
}]
}
在这种情况下,如果员工1更改他的个人资料图片,我需要使完整的缓存对象无效以保持数据一致性。 这种方法破坏了缓存,因为每当我需要清除该完整对象的员工有任何更新时。
有没有更好的方法或设计我们可以遵循优化呢?
感谢
将每个对象存储在不同的密钥中,然后只是使每个密钥无效。或者考虑使用[MongoDB](https://docs.mongodb.com/manual/tutorial/) – thepirat000
以及如何将它存储在MongoDb将解决这个问题? –