Cache component is responsible for holding the data in the memory as a set of Name-Value pairs, identified by one or more designated key Name Value pairs. User can define the data format using the Cache Configuration Property Sheet (CPS). Cache performs different actions like (lookup/add/updated) based on the input data. Cache supports multiple cache entries in a single call and can perform various operations based on the data specified, which means user can updated several entries, lookup data and add new data using a single input message. Cache component also supports Delete operation using special port. By default the cache data remains till the application/cache component is running, however user can configure to clear the cache as per the threshold defined in the CPS.
Cache is designed to represent the data at runtime and doesn't support persistence by default. Cache is cleared as soon as the application/cache component is stopped, resulting in the loss of current data. If the cache data needs to be persisted then use components (DB, File, and so on.), to read the data from cache and persist.
Data in the cache can be accessed by sending a request (input data) to the cache. For the case of single key
-
If Key is Not Null & Data is Not Null then Cache performs Add action if entry doesn't exists in the cache, else perform update action. In either case it returns the new/updated entry.
-
If the key is Not Null and Data is Null then Cache performs Lookup and returns entry if that entry exists, else it logs a message stating the key cannot be looked up.
-
If the key is Null, the message is rejected.
For the case of multiple keys
-
If Key1 & Key2 & data are Not Null, then it performs Add action if entry doesn't exists in the cache, else perform Update action. In either case it returns the new/updated entry.
-
If Key1 & Key2 are Not Null and if data is Null, then it performs Lookup and returns entry if that entry exists, else it logs a message stating the key cannot be looked up.
-
If input data contains only one key then it performs Lookup operation and returns the result of lookup.
-
If input data doesn't contain any key, then cache throws an exception and it is sent to error port of the cache component.