Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does the "check in memory" mean in Orchard CMS?

Tags:

orchardcms

I tried to customize the queries executed by Orchard.ContentManagement.DefaultContentManager but the following peace of code *1 render my efforts useless:

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;
            }
        }

The query is executed correctly and it does not return any data (which was my goal) but afterwards a second attempt *1 is executed to still get the content item.

Why is this part of code there? What is its purpose? Also why does the comment state check in memory and then the repository (DB table) is queried.

like image 727
ViRuSTriNiTy Avatar asked Dec 04 '25 17:12

ViRuSTriNiTy


1 Answers

It's already been verified at this point that the item doesn't exist in the database, but it may have just been created from code during the same request. In that case, the nHibernate session has the item, but the database doesn't have it yet. The repository hits the session, not the db directly, so if it's there, it'll retrieve it, but that'll happen in memory.

like image 88
Bertrand Le Roy Avatar answered Dec 06 '25 15:12

Bertrand Le Roy



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!