cache-offline.js revision ee690f24c60886e1a1f22d53910eb2d93c3a62da
///////////////////////////////////////////////////////////////////////////// // CacheOffline static properties ///////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// // CacheOffline Attributes ///////////////////////////////////////////////////////////////////////////// * @description A string that must be passed in via the constructor. * This identifier is used to sandbox one cache instance's entries * from another. Calling the cache instance's flush and length methods * or get("entries") will apply to only these sandboxed entries. * @description Absolute Date when data expires or * relative number of milliseconds. Zero disables expiration. * @default 86400000 (one day) * @description Always true for CacheOffline. * Removes all items from all sandboxes. Useful if localStorage has * exceeded quota. Only supported on browsers that implement HTML 5 Y.
log(
"All sandboxes of OfflineCache flushed",
"info",
"cache");
Y.
log(
"Could not flush all OfflineCache sandboxes.",
"warn",
"cache");
///////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// * @description Fired when an entry could not be added, most likely due to * exceeded browser quota. * <dt>error (Object)</dt> <dd>The error object.</dd> ///////////////////////////////////////////////////////////////////////////// // CacheOffline protected methods ///////////////////////////////////////////////////////////////////////////// * @param e {Event.Facade} Event Facade with the following properties: * <dt>entry (Object)</dt> <dd>The cached entry.</dd> // Convert Dates to msecs on the way into localStorage Y.
log(
"Cached offline entry: " + Y.
dump(
entry),
"info",
"cache");
" due to error: " + Y.
dump(
error),
"warn",
"cache");
* @param e {Event.Facade} Event Facade object. ///////////////////////////////////////////////////////////////////////////// // CacheOffline public methods ///////////////////////////////////////////////////////////////////////////// * Adds a new entry to the cache of the format * {request:request, response:response, expires: expires}. * @param request {Object} Request value must be a String or JSON. * @param response {Object} Response value must be a String or JSON. * Retrieves cached object for given request, if available. * Returns null if there is no cache match. * @param request {Object} Request object. * @return {Object} Cached object with the properties request, response, // Convert msecs to Dates on the way out of localStorage Y.
log(
"Retrieved offlinecached response: " + Y.
dump(
entry) +