SysCache Query

Topics: Customizing Orchard, General, Writing modules
Aug 30, 2013 at 11:00 AM
Hey,

I have very little knowledge of how caching works and was wondering if someone could clear this up for me. I have a part that contains a count and a list of records, like so:
        public ContentRegistrationPartRecord()
        {
            this.ContentRegistrationRecords = new List<ContentRegistrationRecord>();
        }

        public virtual int Count { get; set; }

        public virtual IList<ContentRegistrationRecord> ContentRegistrationRecords { get; set; }
ContentRegistrationRecords are created when, as the name suggests, a user registers for content. When I need to check if a user is registered to a piece of content I access it as so:
var userRegistered = registrationPart
                      .ContentRegistrationRecords
                      .Any(e => e.PersonPartRecord.Id == this.services.WorkContext.CurrentUser.Id);
However, this does not return the latest data from the database, but what I assume is some cached copy for when I turn off SysCache off it works fine. After roughly five minutes it perks up and gets the new data. But I am getting lots of support calls and emails from people trying to register for content and seemingly being unable to.

If I access the ContentRegistrationRecord repository directly it works perfectly, with caching turned on. So it is working fine, I was just wondering why this is happening? And if it is worth noting, when creating a ContentRegistrationRecord I also update the ContentRegistrationPart with the latest count.

Cheers
Coordinator
Aug 30, 2013 at 8:55 PM
You should file a bug, and in the meantime disable SysCache.
Developer
Aug 30, 2013 at 11:50 PM
I think I may have experienced this too... maybe I should take a look at some point :/
Sep 5, 2013 at 11:00 AM
Sep 25, 2013 at 1:46 PM
Turning off SysCache as Bertrand suggested has fixed all the issues, naturally. But there has been a noticeable drop in performance. I was just wondering if anyone was looking into this?

Cheers
Coordinator
Sep 25, 2013 at 5:11 PM
If you are using it on a website with mostly anonymous users then OutputCaching is a better solution.
Sep 25, 2013 at 5:36 PM
Yeah, our site is mainly for registered users, although we also have outputcaching enabled.

I have begun to modify all the properties that are causing issues to use LazyFields but there are so many properties to change... ^^