kony.net.cache Namespace
The kony.net.cache Namespace contains the following API elements.
Functions
The kony.net.cache namespace implements the caching of responses by mapping HttpReq objects to HttpRes objects.
IMPORTANT: The response size is small enough to reasonably fit within the cache. (For example, if you provide a disk cache, the response must be no larger than about 5% of the disk cache size.
The kony.net.cache namespace contains the following functions.
 kony.net.cache.setMemoryAndDiskCapacity
kony.net.cache.setMemoryAndDiskCapacity
                                                        This API initializes a cache capacity memory and disk with the specified values, which can be invoked as part of the preApp or postApp init of the Quantum Visualizer app.
Syntax
kony.net.cache.setMemoryAndDiskCapacity(memoryCapacity, diskCapacity);
Input Parameters
| Parameter | Description | 
|---|---|
| memoryCapacity(JSNumber) | The memory capacity of the cache, in bytes. | 
| diskCapacity(JSNumber) | The disk capacity of the cache, in bytes | 
Example
setMemoryandDiskCapacity: function() {
    var memory = this.view.tbxMemory.text;
    var disk = this.view.tbxDisk.text;
    kony.net.cache.setMemoryAndDiskCapacity(memory, disk);
    alert("The Memory and Disk Capacity is set");
},
                                                            Return Values
None.
 kony.net.cache.getMemoryCapacity
kony.net.cache.getMemoryCapacity
                                                        This API returns memory capacity of the cache in bytes.
Syntax
kony.net.cache.getMemoryCapacity();
Input Parameters
None
Example
getMemoryCapacity: function() {
    var memoryCapacity = kony.net.cache.getMemoryCapacity();
    alert("The memory capacity of the device is: " + memoryCapacity + "B");
},
                                                            Return Values
Returns memory capacity in bytes of JSNumber.
Platform Availability
- iOS
 kony.net.cache.getDiskCapacity
kony.net.cache.getDiskCapacity
                                                        This API returns disk capacity of the cache, in bytes.
Syntax
kony.net.cache.getDiskCapacity();
Input Parameters
None
Example
getDiskCapacity: function() {
    var diskCapacity = kony.net.cache.getDiskCapacity();
    alert("The disk capacity of the device is: " + diskCapacity + "B");
},
                                                            Return Values
Returns disk capacity in bytes of JSNumber.
Platform Availability
- iOS
 kony.net.cache.getCurrentDiskUsage
kony.net.cache.getCurrentDiskUsage
                                                        This API returns current size of the on-disk cache in bytes.
Syntax
kony.net.cache.getCurrentDiskUsage();
Input Parameters
None
Example
currentDiskUsage: function() {
    var diskUsage = kony.net.cache.getCurrentDiskUsage();
    alert("The current disk usage is: " + diskUsage);
},
                                                            Return Values
Returns current on-disk capacity in bytes of JSNumber.
Platform Availability
- iOS
 kony.net.cache.getCurrentMemoryUsage
kony.net.cache.getCurrentMemoryUsage
                                                        This API returns current size of the in-memory cache, in bytes
Syntax
kony.net.cache.getCurrentMemoryUsage();
Input Parameters
None
Example
currentMemoryUsage: function() {
    var memUsage = kony.net.cache.getCurrentMemoryUsage();
    alert("The current memory usage is: " + memUsage);
},
                                                            Return Values
Returns current in-memory capacity in bytes of JSNumber.
Platform Availability
- iOS
 kony.net.cache.setCacheConfig
kony.net.cache.setCacheConfig
                                                        This API initializes the cacheConfig is a dictionary which configures the cachePolicy and storagePolicy of the cache responses for the request at the app level.
Syntax
setCacheConfig(cacheConfig JSDictionary);
Input Parameters
| Parameter | Description | 
|---|---|
| cacheConfig(JSDictionary) | The cacheConfig is a dictionary which configures the cachePolicy and storagePolicy of the cache responses. cacheConfig Constants The cache config has the following constantsfor cachePolicy: 
 The cache config has the following constantsfor storagePolicy: 
 | 
Example
setCacheConfig: function() {
    var cacheConfig = {
        cachePolicy: kony.net.cache.USE_PROTOCOL_CACHE_POLICY,
        cacheStoragePolicy: kony.net.cache.DISK_AND_MEMORY
    };
    kony.net.cache.setCacheConfig(cacheConfig);
    alert("The Cache Config is set");
}
                                                            Return Values
None
Remarks
This app level setting will be overridden by the per request level setting under widget and api level.
Platform Availability
- iOS
