java 开发中的缓存问题
PHPz
PHPz 2017-04-18 10:00:21
0
2
409

java 开发 把购物车放在 cookie 中 用户登陆后吧信息保存在缓存中,如果此时 在后台 对商品信息进行修改 影响到了缓存中的数据 此时 如何处理!

PHPz
PHPz

学习是最好的投资!

reply all(2)
大家讲道理

For objects with strict timeliness such as products, the background data has been updated, and the places where these data are used should also need to be updated. The observer pattern is usually used to solve this kind of problem, the core of which lies in publish and subscribe. There are many specific implementation solutions. You can use Guava's Eventbus within the application, or you can use nosql such as redis. Personally, it is recommended to use redis to complete it. At the same time, redis can also be used as a second-level cache.

大家讲道理

No matter how you update the product data in the cache, it is very time-consuming and will increase the complexity of the system, and the data may not be updated and read in real time; so it is recommended to store it in the shopping cartskuId和购买的amount , read the product data from the product cache when swiping the shopping cart; and update the product cache after the product is updated, which can reduce the system complexity caused by updating product information and save a lot of memory

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template