Namespace wink.cache
The 'easy caching' component
- Defined in: wink.cache.js
| Constructor Attributes | Constructor Name and Description |
|---|---|
| Compatibility list | Supported platforms / browsers |
|---|---|
|
iOS2, iOS3, iOS4, iOS5, iOS6, Android 2.1, Android 2.2, Android 2.3, Android 3.0, Android 3.1, Android 4.0, BlackBerry 6, BlackBerry 7
|
Method Summary
Namespace Detail
wink.cache
var resources =
[
{ url: '../../_base/_base/js/base.js', type: 'js', group: 0 },
{ url: '../../_base/error/js/error.js', type: 'js', group: 1 },
{ url: '../../_base/json/js/json.js', type: 'js', group: 1 },
{ url: '../../_base/topics/js/topics.js', type: 'js', group: 1 },
{ url: '../../_base/ua/js/ua.js', type: 'js', group: 1 },
{ url: './test.js', type: 'js', group: 2, expires: 60, version: 1.0 }, // Valid for 1 minute
{ url: './test.css', type: 'css', group: 2, expires: 60, version: 1.0 } // Valid for 1 minute
];
var resourcesLoaded = function(result)
{
console.log("loadTime: " + result.loadTime + ", with " + (result.errors.length + result.loadErrors.length) + " errors");
};
wink.load(resources, resourcesLoaded);
Method Detail
-
<static> wink.cache.load(resources, onload, p, options)Loads the resources
- Parameters:
- {array} resources
- The resources to load
- {string} resources.url
- The url of the resource
- {string} resources.type
- The type can be 'js' or 'css'
- {integer} resources.group Optional, Default: 0
- Allows to specify an order of loading: a resource in a group will be loaded before groups with higher indexes
- {integer} resources.expires Optional, Default: options.expires
- The expiration duration in seconds: if not specified, takes the global value (see options), if -1 specified, the existing resource will be deleted
- {string} resources.version Optional, Default: 1.0
- The version of the resource: very useful for versioning of code, an outdated resource is seen as an expired resource
- {function} onload Optional
- A function called once all the resources have been loaded.
- {object} p
- The result parameter passed to the callback function
- {integer} p.loadTime
- The loading duration in ms
- {boolean} p.useOfLocalDatabase
- Specify whether the local database is used (false when an error occurs)
- {array} p.errors
- An array of cache system errors
- {array} p.loadErrors
- An array of network loading errors
- {array} p.resourcesCleaned
- An array of resources cleaned
- {array} p.resourcesOldVersion
- An array of outdated resources deleted
- {object} options Optional
- Options
- {object} options.enable Optional, Default: true
- Specify to use the local storage or not
- {object} options.storage Optional
- The storage type: 'localStorage' / 'sqlDatabase' / 'indexedDatabase'
- {object} options.synchronize Optional, Default: false
- Synchronize resources with local storage or not
- {object} options.expires Optional, Default: 1814400 (3 weeks)
- The global value for expiration duration
- {object} options.dbName Optional, Default: wink
- The name of the database (available for sqlDatabase and indexedDatabase)
- {object} options.dbTable Optional, Default: resources
- The name of the resource table (available for sqlDatabase and indexedDatabase)
- {object} options.dbSize Optional, Default: 5242880 (5 Mo)
- The size of the database in bytes (available for sqlDatabase)
- {object} options.key Optional, Default: wink.ressources
- The key of the data in localStorage (available for localStorage)
-
<static> wink.cache.resetDatabase(onreset, p)Deletes the database content
- Parameters:
- {function} onreset Optional
- A function called once the database is reseted.
- {object} p
- The result parameter passed to the callback function
- {integer} p.errors
- An array of cache system errors