Using the cache - SmartPlant Foundation - IM Update 44 - Customization & Programming - Hexagon

SmartPlant Foundation Customization

Language
English
Product
SmartPlant Foundation
Search by Category
Customization & Programming
SmartPlant Foundation / SDx Version
10

The cache is split into two different types:

  • Process – Persisted only for each server call

  • Application – Persisted as long as the web service is running and not reset

Obviously it's faster to retrieve objects from the cache than the database, and there are a number of methods on the cache class that will help you retrieve object(s). The cache is written in a way that it will load items as and when it needs them (OnDemand model). So, for example, if you have the UID of an object and use the .Item property to retrieve it, and then if it hasn't already got it, it will query the database to get it.

Use the ProcessCache property on the CoreModule class to access the following set of methods:

Name

Description

Contains(uid)

Returns true if object with uid exists in collection.

Contains(uid, domainuid)

As above but ensures the domain matches.

ContainsByObid(obid)

Returns true if object with obid exists.

ItemByObid(obid)

Return the item with obid, will look in cache and then if not found go to the database.

Item(uid)

Return the item with uid, will look in cache and then if not found go to the database.

Item(uid,domain)

As above but looks in a specific domain.

Items(ClassDefinitionUID)

Retrieve all items currently in the cache that have a matching classdefinition UID.

Add(item as IObject)

Adds an item into the cache.

Remove(item as IObject)

Adds an item into the cache.