# Yahoo! UI Library

### cache 3.3.0

Yahoo! UI Library > cache > CacheOffline
Search:
Filters Show Private Show Protected Show Deprecated

## Class CacheOffline - extends Cache

Extends Cache utility with offline functionality.

### Constructor

CacheOffline `( )`

### Properties

#### NAME - `static final String`

Class name.

#### Properties inherited from Plugin.Host:

`PluginHost`

#### Properties inherited from Base:

`name`

#### Properties inherited from Cache:

`_entries`

#### Properties inherited from Attribute:

``

### Methods

#### _defAddFn

`protected void _defAddFn ( e )`
Adds entry to cache.

Parameters:
  `e <Event.Facade>` Event Facade with the following properties:
  entry (Object)
    The cached entry.

#### _defFlushFn

`protected void _defFlushFn ( e )`
Flushes cache.

Parameters:
  `e <Event.Facade>` Event Facade object.

#### _getEntries

`protected void _getEntries ( )`
Gets all entries.

#### _getSize

`protected void _getSize ( )`
Gets size.

#### _setMax

`protected void _setMax ( )`
Always return null.

#### add

`void add ( request , response )`
Adds a new entry to the cache of the format {request:request, response:response, cached:cached, expires: expires}.

Parameters:
  `request <Object>` Request value must be a String or JSON.
  `response <Object>` Response value must be a String or JSON.

#### flushAll

`static void flushAll ( )`
Removes all items from all sandboxes. Useful if localStorage has exceeded quota. Only supported on browsers that implement HTML 5 localStorage.

#### retrieve

`Object retrieve ( request )`
Retrieves cached object for given request, if available. Returns null if there is no cache match.

Parameters:
  `request <Object>` Request object.

Returns: `Object`
  Cached object with the properties request, response, and expires, or null.

#### Methods inherited from EventTarget:

`_getType, _monitor, _parseType, addTarget, after, before, bubble, detach, detachAll, fire, getEvent, getTargets, on, once, parseType, publish, removeTarget, subscribe, unsubscribe, unsubscribeAll`

#### Methods inherited from Base:

`_aggregateAttrs, _defDestroyFn, _defInitFn, _destroyHierarchy, _filterAttrCfs, _getAttrCfgs, _getClasses, _initHierarchy, _initHierarchyData, _preInitEventCfg, destroy, init, toString`

#### Methods inherited from Plugin.Host:

`_destroyPlugins, _initPlugins, hasPlugin, plug, unplug`

#### Methods inherited from Cache:

`_defAddFn, _defFlushFn, _getEntries, _getSize, _isMatch, _setMax, add, destructor, flush, initializer, retrieve`

#### Methods inherited from Attribute:

`_addAttrs, _addLazyAttr, _defAttrChangeFn, _fireAttrChange, _getAttr, _getAttrCfg, _getAttrInitVal, _getAttrs, _getStateVal, _isLazyAttr, _normAttrVals, _protectAttrs, _set, _setAttr, _setAttrs, _setAttrVal, _setStateVal, addAttr, addAttrs, attrAdded, get, getAttrs, modifyAttr, removeAttr, reset, set, setAttrs`

### Events

#### error

`error ( )`
Fired when an entry could not be added, most likely due to exceeded browser quota.

error (Object)
  The error object.

#### expiresChange

`expiresChange ( event )`
Fires when the value for the configuration attribute 'expires' is changed. You can listen for the event using the on method if you wish to be notified before the attribute's value has changed, or using the after method if you wish to be notified after the attribute's value has changed.

Parameters:
  `event <Event.Facade>` An Event Facade object with the following attribute specific properties added:
  prevVal
    The value of the attribute, prior to it being set
  newVal
    The value the attribute is to be set to
  attrName
    The name of the attribute being set
  subAttrName
    If setting a property within the attribute's value, the name of the sub-attribute property being set

#### maxChange

`maxChange ( event )`
Fires when the value for the configuration attribute 'max' is changed. You can listen for the event using the on method if you wish to be notified before the attribute's value has changed, or using the after method if you wish to be notified after the attribute's value has changed.

Parameters:
  `event <Event.Facade>` An Event Facade object with the following attribute specific properties added:
  prevVal
    The value of the attribute, prior to it being set
  newVal
    The value the attribute is to be set to
  attrName
    The name of the attribute being set
  subAttrName
    If setting a property within the attribute's value, the name of the sub-attribute property being set

#### sandboxChange

`sandboxChange ( event )`
Fires when the value for the configuration attribute 'sandbox' is changed. You can listen for the event using the on method if you wish to be notified before the attribute's value has changed, or using the after method if you wish to be notified after the attribute's value has changed.

Parameters:
  `event <Event.Facade>` An Event Facade object with the following attribute specific properties added:
  prevVal
    The value of the attribute, prior to it being set
  newVal
    The value the attribute is to be set to
  attrName
    The name of the attribute being set
  subAttrName
    If setting a property within the attribute's value, the name of the sub-attribute property being set

#### uniqueKeysChange

`uniqueKeysChange ( event )`
Fires when the value for the configuration attribute 'uniqueKeys' is changed. You can listen for the event using the on method if you wish to be notified before the attribute's value has changed, or using the after method if you wish to be notified after the attribute's value has changed.

Parameters:
  `event <Event.Facade>` An Event Facade object with the following attribute specific properties added:
  prevVal
    The value of the attribute, prior to it being set
  newVal
    The value the attribute is to be set to
  attrName
    The name of the attribute being set
  subAttrName
    If setting a property within the attribute's value, the name of the sub-attribute property being set

#### Events inherited from Base:

`destroy, destroyedChange, init, initializedChange,`

#### Events inherited from Cache:

`add, entriesChange, expiresChange, flush, maxChange, request retrieve sizeChange uniqueKeysChange`

### Configuration Attributes

#### expires `- Date | Number`

Absolute Date when data expires or relative number of milliseconds. Zero disables expiration.
Default Value: 86400000 (one day)

#### max `- object`

Disabled.
Default Value: null

#### sandbox `- String`

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.
Default Value: "default"

#### uniqueKeys `- object`

Always true for CacheOffline.
Default Value: true

#### Configuration attributes inherited from Base:

`destroyed initialized`

#### Configuration attributes inherited from Cache:

`entries, expires, max size uniqueKeys`

Copyright © 2011 Yahoo! Inc. All rights reserved.