奇怪的兑现问题 [英] weird cashing question

查看:89
本文介绍了奇怪的兑现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我有一个奇怪的问题,我正在使用果园cms,并且试图隐瞒兑现.

这是代码:

 ObjectCache缓存= MemoryCache.Default;
..
var contentItemShapes = gefilterd.Select(x => checkCache(cache,x,displayType)).ToList();
..
        私有对象checkCache(ObjectCache cache,ContentItem r,String displayType)
        {
            如果(!cache.Contains(r.Id.ToString()))
            {
                CacheItemPolicy策略= new CacheItemPolicy();
                policy.AbsoluteExpiration = DateTimeOffset.Now.AddDays(1);
                cache.AddOrGetExisting(r.Id.ToString(),_contentManager.BuildDisplay(r,displayType),policy);
            }
            返回缓存[r.Id.ToString()];
            
        } 

第一个加载项目按原样显示,当我调试时,我看到它们被正确地注入了现金.

现在,第二次加载时,对象以不同的方式出现,存在诸如元数据"之类的属性.在对象contentitem上,它们看起来与在第一次加载时完全不同,这使我很惊讶,因为当您进入循环时,它不会 甚至因为已被缓存而被更改.

有人知道这可能是什么吗?

解决方案

确实很难说,但我怀疑这与它有关您存储在缓存中的对象.我们不知道BuildDisplay返回什么,但是如果它返回一个基础系统正在更改的对象,那么您将得到奇怪的行为.这个 对于Orchard团队来说,这听起来确实像是一个问题,所以您应该在他们的论坛上发帖.我怀疑您要取回的对象不是为了缓存而设计的,因为它很可能代表当前上下文的UI信息.如果上下文改变,则对象 实际上是无效的.

对于与如何缓存Orchard显示有关的问题,您应该在他们的论坛中发帖.

迈克尔·泰勒
http://www.michaeltaylorp3.net


Hey everyone,

I have a weird problem, i'm using orchard cms and i'm trying to impliment cashing.

This is the code:

ObjectCache cache = MemoryCache.Default;
..
var contentItemShapes = gefilterd.Select(x => checkCache(cache, x, displayType)).ToList();
..
        private object checkCache(ObjectCache cache, ContentItem r, String displayType)
        {
            if (!cache.Contains(r.Id.ToString() ))
            {
                CacheItemPolicy policy = new CacheItemPolicy();
                policy.AbsoluteExpiration = DateTimeOffset.Now.AddDays(1);
                cache.AddOrGetExisting(r.Id.ToString() , _contentManager.BuildDisplay(r, displayType), policy);
            }
            return cache[r.Id.ToString() ];
            
        }

The first load items are displayed as it should, when I debug i see them being injected corretcly in the cash.

Now the second time i load, the objects come out differently, there are properties like "metadata" on the object contentitem and they look completely different then on the first load which freaks me out becouse when you enter the loop it doesn't even get changed because it's already cached.

Does anyone know what this could be?

解决方案

It is really hard to say but I suspect it has something to do with the object you're storing in the cache. We have no idea what BuildDisplay returns but it if returns an object that the underlying system is changing then you will get bizarre behavior. This really sounds like a question for the Orchard team so you should post in their forums. I suspect the object you're getting back isn't designed to be cached as it likely represents the current context's UI information. If the context changes then the object is effectively invalid.

For questions related to how to cache Orchard displays you should post in their forums.

Michael Taylor
http://www.michaeltaylorp3.net


这篇关于奇怪的兑现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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