Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

如果缓存的数据有修改需求,最佳实践是什么? #9

Closed
Cloud33 opened this issue Mar 11, 2022 · 2 comments
Closed

如果缓存的数据有修改需求,最佳实践是什么? #9

Cloud33 opened this issue Mar 11, 2022 · 2 comments

Comments

@Cloud33
Copy link

Cloud33 commented Mar 11, 2022

存放对象 or 指针(深拷贝后在副本上修改)?

修改的次数比较多,对象结构复杂(对象有三四层)

@orca-zhang
Copy link
Owner

深拷贝是最朴素的做法,相对来说消耗比较大,对于比较大的对象来说,和bigcache、freecache用法就接近了,体现不出ecache的优势。

更好的方案是,如果再上层涉及到协议层传输转换的话,比如使用pb、json、form-data等,也可以考虑到这一层加缓存,并且对有差异的部分打补丁(补丁部分也可以单独缓存),也就是在快发出去之前做数据组装和修订即可。

@Cloud33
Copy link
Author

Cloud33 commented Mar 17, 2022

明白,谢谢

@Cloud33 Cloud33 closed this as completed Mar 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants