User Guide: SDKs > VoltMX Iris SDK > Cache Service Response for Integration and Object Service
Cache Service Response for Integration and Object Service
The Cache service response feature provides a non -persistent cache for storing response from integration and object service operations. The stored response can be retrieved by cacheID. Consequently, you can avoid making additional network calls for read-only data.
Usage | Optional parameters useCache, cacheID and expiryTime are used to save and retrieve the responses from the cache for both Integration Service and Object Service. Note: Cache size is 100 by default .
| ||||||||||||||||||||||
Features Supported | Integration Service, Object Service fetch | ||||||||||||||||||||||
Platforms Supported | IDE | ||||||||||||||||||||||
Scope | The scope of the feature is limited to the application level. | ||||||||||||||||||||||
API | IntegrationIntegrationClient.invokeOperation(operationName, headers, params, successCallback, failureCallback, options)
Object Service ObjectClient.fetch(options, successCallback, failureCallback)
|
Note: You can remove any key from cache explicitly using new voltmx.sdk.ClientCache().remove(cacheID) .
Sample Code
//Integration Service
function cache_integration_svc_response() {
var options = {};
var responseCacheKey;
options["useCache"] = true;
//Optional
//options["cacheID"] = "cachedEmployeeDetailsResponse";
//options["expiryTime"] = 30; - Assign expiry time for the current response if desired
try {
var serviceName = "integration_service_name";
// Get an instance of SDK
var client = voltmx.sdk.getCurrentInstance();
var integrationSvc = client.getIntegrationService(serviceName);
var operationName = "operation_name";
integrationSvc.invokeOperation(operationName, null, null,
function(response) {
// Save the response cache key
responseCacheKey = response["cacheID"];
voltmx.print("Success: " + JSON.stringify(response));
},
function(error) {
voltmx.print("Failure: " + JSON.stringify(error));
},
options);
// Try fetching employee details using cacheID
options = {};
options["useCache"] = true;
options["cacheID"] = responseCacheKey;
integrationSvc.invokeOperation(operationName, null, null,
function(response) {
// Save the response cache key
responseCacheKey = response["cacheID"];
voltmx.print("Success: " + JSON.stringify(response));
},
function(error) {
voltmx.print("Failure: " + JSON.stringify(error));
},
options);
} catch (exception) {
alert("Integration Service Connect Failed " + exception.message);
}
}
//Object Service
function cache_object_svc_fetch() {
var responseCacheKey;
var objSvc = voltmx.sdk.getCurrentInstance().getObjectService(serviceName, {
"access": "online"
});
var dataObject = new voltmx.sdk.dto.DataObject("ObjectName");
var options = {
"dataObject": dataObject
};
options["useCache"] = true;
//Optional
//options["cacheID"] = "cachedEmployeeDetailsResponse";
//options["expiryTime"] = 30; - Assign expiry time for the current response if desired
objSvc.fetch(options,
function(response) {
responseCacheKey = successRes["cacheID"];
voltmx.print("Success: " + JSON.stringify(response));
},
function(error) {
voltmx.print("Failure: " + JSON.stringify(error));
});
// Try fetching employee details using cacheID
options = {};
options["useCache"] = true;
options["cacheID"] = responseCacheKey;
objSvc.fetch(options,
function(response) {
responseCacheKey = successRes["cacheID"];
voltmx.print("Success: " + JSON.stringify(response));
},
function(error) {
voltmx.print("Failure: " + JSON.stringify(error));
});
}