Copyright © TIBCO Software Inc. All Rights Reserved
Copyright © TIBCO Software Inc. All Rights Reserved


Chapter 8 Cache Modes and Project Design : Loading Cache Only Objects into the Rete Network

Loading Cache Only Objects into the Rete Network
When you use Cache Only mode for an entity type, objects of that type behave normally when they are created during an RTC (see Understanding Conflict Resolution and Run to Completion Cycles for more details). At the end of an RTC, however, they are removed from the Rete network and written to the cache.
Cache Load Functions
You must explicitly load Cache Only objects into the Rete network when they will be needed during an RTC, using an appropriate cache load function in the DataGrid function category, within the Cluster category:
CacheLoadConceptByExtId()
CacheLoadConceptsByExtId()
CacheLoadConceptById()
CacheLoadEventByExtId()
CacheLoadEventById()
CacheLoadParent()
Less-commonly used:
CacheLoadConceptByExtIdByUri()
CacheLoadConceptIndexedByExtId()
CacheLoadEntity()
cacheLoadEventByExtIdByUri()
loadConceptUsingExtId()
Contained concepts
The functions that load concepts by ExtID or ID have a parameter to control whether contained concepts are also loaded. The CacheLoadParent() function, which loads a given concept’s parents, has the option to return all parents or the immediate parent. (Parents are concepts related to the given concept by a containment relationship).
Referenced Concepts  You must explicitly load all referenced concepts as needed. Only containment relationships can be handled automatically.
Use in preprocessor
A general best practice is to use these functions in an event preprocessor. Event preprocessors are multithreaded so performance is better. Also, if you load the objects in the preprocessor, then the rules themselves do not have to take account of the need to load the objects during execution. For example, in the preprocessor, you could preload an order concept using an ExtID available in the event as follows:

 
Concepts.Order order = Cluster.DataGrid.CacheLoadConceptByExtId(orderevent.Order_Id, false);

 
Loaded Objects Are Not New and Do Not Trigger Rules to Fire
The loaded objects do not behave like newly arrived entities. They are not asserted: their presence alone does not trigger rules. They are simply restored to the Rete network. They behave as if they had never been removed. For example, rules do fire if there is a join condition between the entity loaded from cache and another entity that is asserted or modified in the same RTC.
Also if you modify the object that you reloaded, it can trigger the rule.
Limited Use of getByExtId()  Only use this function to retrieve Cache Only objects that have already been loaded into the Rete network by a preprocessor. The getByExtId() function does not load the object into the Rete network.
 

Copyright © TIBCO Software Inc. All Rights Reserved
Copyright © TIBCO Software Inc. All Rights Reserved