Rails 3.1 身份映射问题?
有谁知道 Rails 3.1 IdentityMap 功能的关键问题导致默认情况下强制禁用该功能?我确信存在一些小具体问题,但是在为已构建的 Rails 3.1 应用程序启用它之前,是否有任何人应该注意的重大问题?
Does anyone know the key issues that the Rails 3.1 IdentityMap feature has that has forced the feature to be disabled by default? I'm sure that there are minor specific issues, but are there any major issues that anyone should be aware of before enabling it for an already built Rails 3.1 application?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
从代码中的注释:
From the comments in the code:
当您查看文档时,主要问题提出的问题是,身份映射中管理的对象尚无法处理关联,因此它现在还没有完全准备好用于现实世界。
该文档明确指出该功能仍在开发中,因此没有人应该真正在野外使用它。
When you look at the documentation the main issue raised is that objects managed in the Identity Map can not handle associations yet, so it's not quite ready for real world usage right now.
The documentation states clearly that the feature is still under development, so no one should really be using it in the wild.
我知道的两个小问题是:
如果您继承模型,并且想要从一种拼写错误的对象切换到另一种对象,那么首先您需要从身份映射中删除对象,然后创建一个新对象。示例:
另一个小问题是恒等映射可能会与测试中的内容相符。因为它不会在每次测试后截断其存储库。为了做到这一点,需要将其添加到测试框架配置中。 Rspec 示例:
我的意见是可以使用恒等映射,但部分使用。默认情况下为每个单个对象启用它是一个坏主意,但为特定模型启用它是一个好主意。假设您有一个语言表,这是相当静态的数据,或者可能按国家/地区划分。为什么不将它们全部加载到身份映射中。但是,对于动态数据(例如用户或不断变化的不同数据),无需将其存储在内存中。
Two minor problems which I aware of are:
If you inheriting models, and you want to switch from one typo of object to another, then first you need delete your object from identity map, and after that create a new object. Example:
Another small issue is that the identity map may mees up the thing in the tests. As it do not truncates its repository after each test. To make it to do so one needs to add that into test framework configurations. Rspec example:
My opinion is that identity map may be used, but partially. It is a bad idea to enable it by default for each single object, but it will be a good idea to enable it to specific models. Say, you have a table of languages, which is pretty static data, or may by countries. Why not to load them all in to identity map. But, with dynamic data (like users, or something different, that constantly changes), there is no need to store that in the memory.