无论如何要减少序列化的开销 [英] Anyway to reduce the overhead of serialization

查看:100
本文介绍了无论如何要减少序列化的开销的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道添加到缓存中的对象需要可序列化。但是我的对象大小变得非常大(考虑到我们的内存容量)。有没有办法处理这个问题,比如可能将对象的信息存储为带分隔符的单个
字符串,然后添加它们然后在检索后解析字符串?这会减少缓存的对象大小吗? (实际上,手动序列化和反序列化)

I understand that the objects that are added to the cache need to be serializable. However my object size is getting very large (Having our memory capacity in mind). Is there a way to handle this, like may be storing the information of the object as a single string with delimiters and then adding them and then parsing the string after retrieval? Does this reduce the cached object size? (In effect, manual serialization and deserialization)

谢谢

推荐答案

您可以将其转换为Byte数组,然后将该字节数组存储在Cache中。是内存使用量的开销还是性能?根据我的经验,如果您每次从主机检索/保存数据,由于冻结和反序列化将导致显着的
性能损失。尝试使用本地缓存来提高获取性能。
You can convert it into a Byte array and then store that byte array in the Cache. Is the overhead in terms of memory usage or is it performance too? Based on my experience, if you retrieve/save data from/to the Host each time, there will be a significant performance penalty involved due to serilization and deserialization. Try using local cache to improve the fetch performance.


这篇关于无论如何要减少序列化的开销的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆