Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

A few questions about SysGlobalObjectCache

(0) ShareShare
ReportReport
Posted on by 1,673

Hi everyone

I've just got a few questions relating to SysGlobalObjectCache; I know there is good help around, but I'm struggling to find a few answers... (The best source I think is https://blogs.msdn.microsoft.com/axperf/2011/12/29/using-sysglobalobjectcache-sgoc-and-understanding-its-performance-implications/)

Here are some questions:

1) To 'Connect' to or instantiated a SysGlobalObjectCache object, you use

SysGlobalObjectCache sgoc = new SysGlobalObjectCache();

Since a singleton pattern is used, this will always return the current instance of the object. Why then do I see cache being retrieved like this (what's the gain?):

    if(classfactory) 
    { 
            c = classfactory.globalObjectCache(); 
    } 
    else 
    { 
           c = new SysGlobalObjectCache(); 
    } 

2) According the article above, "the SGOC will propagate “clear” calls to all clients and other AOS instances"; I presume Cache is cleared automatically as it gets full. Does the 'clear' method that gets propagated flush per scope, or per key or per value etc? How much cache gets flushed when clear is called?

Thank you

*This post is locked for comments

  • BrandonSA Profile Picture
    1,673 on at
    RE: A few questions about SysGlobalObjectCache

    Hi Gents

    Thanks for the help. I found what I was looking for in the end, mostly thanks to the help here. Your last comment was helpful. Thank you Martin

  • Martin Dráb Profile Picture
    234,044 Most Valuable Professional on at
    RE: A few questions about SysGlobalObjectCache

    By they way, what are you trying to achieve by using SysGlobalObjectCache in such a way? It looks like you're trying to pass things to another class through global data, which isn't very safe and maintainable.

  • Martin Dráb Profile Picture
    234,044 Most Valuable Professional on at
    RE: A few questions about SysGlobalObjectCache

    I merged the threads, because Ievgen's reply is very relevant to the first question, which wasn't even mentioned in the new thread.

  • Suggested answer
    Mea_ Profile Picture
    60,278 on at
    RE: SysGlobalObjectCache CIL

    Hi BrandonSA,

    I'm able to reproduce your issue on AX 2012 R3 CU10. I looked at standard usage of SysGlobalObjectCache and found code you asked about previously, but with interesting comment in a Global class, currentWorker() method:

        //Try put pull from cache first
        if (classfactory)
        {
            sgoc = classfactory.globalObjectCache();
        }
        else
        {
            // Workaround for SysQueryRangeUtil usage under IL
            // the class factory is not initialized in the interpreter
            // when called from IL.This is OK as the global cache is a kernel
            // singleton
            sgoc =  new SysGlobalObjectCache();
        }

    It literally says that cache created outside of IL does not exists in IL, so it is not a bug but "feature".

  • BrandonSA Profile Picture
    1,673 on at
    RE: A few questions about SysGlobalObjectCache

    Hi Martin

    I thought I understood what the problem is but I'm still running into trouble. What happens is as I explain below. I capture a value from the user on the client side, cache the value using both the client and server versions of classFactory/cache etc, but then can't access the value again while the code is running on CIL.

    Could you please explain to me where I'm misunderstanding this?

    Thanks

  • BrandonSA Profile Picture
    1,673 on at
    RE: A few questions about SysGlobalObjectCache

    Hi Martin

    I think you answer my question the way you answered someone else here...

    dynamicsuser.net/.../sysglobalcache-thread

  • BrandonSA Profile Picture
    1,673 on at
    RE: A few questions about SysGlobalObjectCache

    I mean that I have a class, and in that class is a method which contains something like:

    SysGlobalObjectCache cache = new SysGlobalObjectCache();

    cache.insert(scope, [key], [val]);

    Then there is another method that retrieves the data. Inside of that method there is code like:

    SysGlobalObjectCache cache = new SysGlobalObjectCache();

    if (cache.find(scope, [key]) != conNull())

    {

       [val] = cache.find(scope, [key]);

    }

    When I run this code, val is cached, but when I try to retrieve this val, I can, as long as I'm not running code on CIL. (ie. Unchecked my 'Execute Business Operations in CIL' checkbox in user options'. As soon as I check this box, ie. Run code in CIL, then val isn't retrieved correctly anymore. I ca write a job to retrieve the value and it works, but it isn't retrieved correctly by the code running in CIL.

    So I was wondering if there is a reason for this. Does tier make a difference as ievgen has suggested?

    Thanks

  • Martin Dráb Profile Picture
    234,044 Most Valuable Professional on at
    RE: A few questions about SysGlobalObjectCache

    Brandon, do you mean that you put data to SCOG in X++ and try to read it in CIL? Or do you do both in CIL?

  • Verified answer
    Mea_ Profile Picture
    60,278 on at
    RE: A few questions about SysGlobalObjectCache

    Hey BrandonSA,

    It's probably not a singleton, if you read comments from Ganas1 and Michael Fruergaard Pontoppidan you could find that it is AOS specific and has server and client version. So you need to check if it is created and used on same AOS and same tier.

  • BrandonSA Profile Picture
    1,673 on at
    RE: A few questions about SysGlobalObjectCache

    Thanks for the reply Martin

    I do have another question that was meant to be part of this post which is more important than the others...

    I have data that is cached correctly and I can retrieve it, but I can only retrieve it when NOT running on CIL.

    Do you know why NOTHING is returned when running on CIL? Do you know how I can cache data so that it is accessible when called on CIL etc?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Jainam Kothari – Community Spotlight

We are honored to recognize Jainam Kothari as our June 2025 Community…

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Mohamed Amine Mahmoudi Profile Picture

Mohamed Amine Mahmoudi 100 Super User 2025 Season 1

#2
Community Member Profile Picture

Community Member 50

#3
shanawaz davood basha Profile Picture

shanawaz davood basha 6

Featured topics

Product updates

Dynamics 365 release plans