新公司在用lumen重构做微服务api框架,上面安排在lumen原有基础上再封装一套缓存操作的类库,想问问这方面有什么需要注意的.
目前架构师给的建议有
未连接上redis或者memcache时取真实数据
get获取缓存时候检测是否缓存中存在改key
set时在设置有效时长基础上随机+1-10秒
滿天的星座2017-04-26 09:04:05
The most important thing is to ensure the unity of cache and real data.
If the read cache misses, read the real data, read and write to the cache
Write/delete/modify the real data first, and then operate the cache after success.
The operations of cache and real data must be consistent. Read-write locks can be used to control the problem of old data being acquired by the cache during the period after the real data is operated on.