5 Replies Latest reply on Mar 14, 2019 1:07 PM by fmocke

    AF Event Frame Static Attributes Cached

    Lonnie Bowling

      Hi Everyone,


      I'm having an issue with static attributes for an event frame not getting the most recent values. Here is what I am doing:


      This is the test code:


                  List < AFSearchToken > tokenList = new List<AFSearchToken>();
                  var name = "T001 - 2018-05-23 21:20:19.000";
                  tokenList.Add(new AFSearchToken(AFSearchFilter.Name, AFSearchOperator.Equal, name));
                  var search = new AFEventFrameSearch(afDb, "optional name", tokenList);
                  var data = search.FindEventFrames(pageSize: 1, startIndex: 0, fullLoad: true);
                  foreach (var e in data)
                      foreach (var attribute in e.Attributes)
                          var value = attribute.GetValue();
                              Console.WriteLine($"{attribute.Name} - {value.ToString()}");


      I repeat this query (without closing my connection) and get back the same values, even after I make a change to an attribute using PSE.  If I restart the application I get the new values, if I do a afDb.Refresh(), I get the new values. Is this the intended behavior?


      Any help would be greatly appreciated!



        • Re: AF Event Frame Static Attributes Cached
          Mike Zboray

          Yes this is how AFElement works as well, however there's one wrinkle. You must refresh the object (Element or EventFrame) to get the latest static attribute values only for attributes where IsConfigurationItem is true (or "Configuration Item" in the UI). By default all static attributes are configuration items. Perhaps a simple refresh (of the event frame or the database) will suffice but sometimes that is too slow. You have two options then. One is to use FindChangedItems to poll for changes and use AFChangeInfo.Refresh to bulk refresh objects. Another is to simply dump the entire cache using new PISystem(true). Note that you need that true parameter force initialization of a new cache or the default cache will be reused and have all the same stale objects. The latter approach can be expensive since your client then needs to reestablish a connection to the server.

          3 of 3 people found this helpful
            • Re: AF Event Frame Static Attributes Cached
              Lonnie Bowling

              Hi Mike,


              Thanks for taking the time to answer my question. Here is how my event frame template is setup:



              As you can see the attribute is not set as a configuration item. I know how that works, so made sure that it was not checked (it is not set by default). So back to my original question. Why would this not work? I really don't have the option of dumping the entire cache. I can try to do the find changes items you suggest, but it seem to me that I should pick up the new values if the static field is not set as a configuration item, what do you think?


              I don't think I have ran into this before, because I always made changes from the same application that was then reading the values (so the changes were updated in the cache). In this situation, I have a long running application that is reading values, but those values may be updated externally.