Global variables and threads

Options
I'm having trouble with global variables and I think I need a little help or advice. Note that I am aware of the difference between $$ (thread local) and $ (application scope)A request is made to my ospace module on (for example) thread 1I have detected that my cache $PRUserCache is not defined so I create it using $PRUserCache = Assoc.CreateAssoc() and add some info to the assoc using $PRUserCache(username) = contextid (the parameters are ok) I then dump out the global var $PRUserCache to make sure what I set is actually set - everything is ok.So far so good.A little time later another request is made and thread 2 in LL decides to pick up the request and process it for me. If I now check $PRUserCache it is *not* defined and thus gets re-initialized which for a cache is a dead loss.Am I missing something here?I have tried this both using a feature defined in my module $PR.PRUserCache as well as just using $PRUserCacheThanks in advance,-- Jason

Comments

  • is there a real time constraint like you cannot rely on a database call to give you shared info perhaps like kiniprefs objects.If you have such a time bound requiremnt check this or the development discussions where Ralf poser of sta solutions participate.I beleive livelink's blocking threads are spawned parallel processes so one does not get the other's info.I do not understand threadsafety really well but some info that others have given me.
  • Message from Hans Stoop <hstoop@opentext.com> via eLink

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">eLink
    Please don't store info in KIni that is updated regulary as side effect of executing a request. This can slow down Livelink  considerably starting from 9.7.1.
    In 9.7.1 all changes to KIni are propagated to all threads that will be triggered to update their KIni caching.
    Use another (your own)  table in stead.

    Hans


    From: eLink Discussion: Livelink Builder Discussion [mailto:componentbuilder@elinkkc.opentext.com]
    Sent: Monday, October 05, 2009 8:37 PM
    To: eLink Recipient
    Subject: is there a real time constraint like you cannot rely on a database call to give...

     

    is there a real time constraint like you cannot rely on a database call to give...   Posted by anair@alitek.com (Nair, Appu) on 2009/10/05 14:34
    In reply to: Global variables and threads   Posted by david.cornwell@pleasetech.com (Cornwell, David) on 2009/10/05 11:45
     
    is there a real time constraint like you cannot rely on a database call to give you shared info perhaps like kiniprefs objects.If you have such a time bound requiremnt check this or the development discussions where Ralf poser of sta solutions participate.I beleive livelink's blocking threads are spawned parallel processes so one does not get the other's info.I do not understand threadsafety really well but some info that others have given me.