"check in memory" 在 Orchard CMS 中是什么意思?
What does the "check in memory" mean in Orchard CMS?
我尝试自定义由 Orchard.ContentManagement.DefaultContentManager
执行的查询,但以下和平代码 *1
使我的努力无用:
class DefaultContentManager
{
...
public virtual ContentItem Get(int id, VersionOptions options, QueryHints hints) {
...
// implemention of the query comes here
...
*1 -> // no record means content item is not in db
if (versionRecord == null) {
// check in memory
var record = _contentItemRepository.Get(id);
if (record == null) {
return null;
}
versionRecord = GetVersionRecord(options, record);
if (versionRecord == null) {
return null;
}
}
查询已正确执行,它没有 return 任何数据(这是我的目标),但之后执行了第二次尝试 *1
以仍然获取内容项。
为什么会有这部分代码?它的目的是什么?还有为什么评论状态 check in memory
然后查询存储库 (DB table)。
此时已经验证该项目不存在于数据库中,但它可能只是在同一请求期间通过代码创建的。在那种情况下,nHibernate 会话有项目,但数据库还没有。存储库命中会话,而不是直接访问数据库,所以如果它在那里,它会检索它,但这会发生在内存中。
我尝试自定义由 Orchard.ContentManagement.DefaultContentManager
执行的查询,但以下和平代码 *1
使我的努力无用:
class DefaultContentManager
{
...
public virtual ContentItem Get(int id, VersionOptions options, QueryHints hints) {
...
// implemention of the query comes here
...
*1 -> // no record means content item is not in db
if (versionRecord == null) {
// check in memory
var record = _contentItemRepository.Get(id);
if (record == null) {
return null;
}
versionRecord = GetVersionRecord(options, record);
if (versionRecord == null) {
return null;
}
}
查询已正确执行,它没有 return 任何数据(这是我的目标),但之后执行了第二次尝试 *1
以仍然获取内容项。
为什么会有这部分代码?它的目的是什么?还有为什么评论状态 check in memory
然后查询存储库 (DB table)。
此时已经验证该项目不存在于数据库中,但它可能只是在同一请求期间通过代码创建的。在那种情况下,nHibernate 会话有项目,但数据库还没有。存储库命中会话,而不是直接访问数据库,所以如果它在那里,它会检索它,但这会发生在内存中。