caching features
Cache used to store temporary data on mobile (RSS feed, news, ...). Data are
stored in RMS or in memory.
Advantages:
- data are loaded only at first access. After, we use the cached data.
- cache access are quickly than HTTP or file access.
Warning:
The cache does not know whether the data are outdated.
The lifetime of the data must be managed by the developer.
Questions on the data to be registered in cache:
- are the data often accessed by user? if not: registering the data in record store can be useless.
- quantity of data? if there is a lot of data: registering them in record store can slow the application.
- is the lifecycle of data short? if it is short: you should configure a short cache delay so cache may not be often used
The cache access is done through Javacript APIs.
To use cache, use an URL in two part, separated by a comma.
- first part, the cache resource URL (cache://...)
- second part, the resource URL (file://..., http://... or other URL)
- third part (optional), asynchronous access (a boolean - true = synchronous / false = asynchronous)
example:
The cache is dependent on the widget. A widget cannot read another widget cache.
The cache scope is the current widget.
We cannot reuse data in cache between two widgets.