哪个 Android/Java ORM 使用“对象缓存”?就像 Hibernate 那样?
我看到了很多关于 Hibernate 的轻量级替代品的问题,特别是对于 Android。但其中哪一个具有“身份地图”图案呢?
此模式确保表示数据库中的行的任何对象在任何会话中仅存在一次。 – 它有助于我的程序保持一致:如果我在某处更改映射对象,则它在各处都会更改(因为所有引用都指向同一对象)。如果我通过新的数据库查询重新获取对象,或者仍然保留之前调用的对象,这并不重要:ORM 确保它们的行为都是相同的。
Hibernate 在它的“一级缓存”中执行此操作。
I saw a bunch of questions about lightweight alternatives to Hibernate, especially for Android. But which of them has the “Identity Map” pattern?
This pattern makes sure that any object representing a row in the db exists only once in any session. – It helps my program to be consistent: if I change a mapped object somewhere, it is changed everywhere (because all references point to the same object). It doesn’t matter if I re-fetch the object via a new database query, or still have it around from earlier calls: the ORM makes sure they all behave like the same thing.
Hibernate does this in it’s “level 1 cache”.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
ORMLite 是一个 Android ORM 包,自 4.26 版(2011 年 9 月 26 日发布)起,首次包含内部对象缓存。 ORMLite 没有“会话”模式,但用户可以将缓存注入任何 DAO 中,并且可以在选择时刷新它。这是缓存支持的文档。
从手册中引用,缓存支持以下内容:
ORMLite 核心包中包含 2 个对象缓存实现。一种支持弱/软引用,另一种是标准 LRU。
与 Hibernate 的 1 级缓存相比,它[显然]是一个非常简单的实现。欢迎反馈。
ORMLite is an Android ORM package that as of version 4.26 (released on 9/26/2011) contains a first take on an internal object cache. ORMLite does not have a "session" pattern but the user can inject a cache into any DAO and can flush it whenever they choose. Here are the docs for the cache support.
To quote from the manual, the cache supports the following things:
There are 2 object cache implementations included with the ORMLite core package. One that supports weak/soft references and another that is a standard LRU.
It is [obviously] a very simple implementation compared to Hibernate's level 1 cache. Feedback welcome.
greenDAO 支持 类似于 Hibernate 的会话,并且带有身份范围。在会话内,实体由 ORM 层跟踪。
greenDAO supports sessions similar to Hibernate and comes with an identity scope. Within a session, entities are tracked by the ORM layer.
我正在尝试做同样的事情。
您听说过 https://github.com/iainconnor/ObjectCache 吗?
我将一一存储列表的长度和所有项目。
如果我已经完成了自己的实现,请回复您,
干杯,Karoly
I`m trying to do the same.
Have you hear about https://github.com/iainconnor/ObjectCache ?
I`m going to store the length of the list and all item one by one.
Get back to you, if I had done with my own implementation
Cheers,Karoly