+
+
+
+
+
+
+
+
+ Class Cache
+
+ - extends Plugin.Base
+
+
+
+
+
+
+ - Known Subclasses:
+ -
+
+ DataSourceCache
+
+
+
+
+
+
+
+ Base class for the YUI Cache utility.
+
+
+
+
Constructor
+
+
+
Cache
+
+ (
+ )
+
+
+
+
+
+
+
+
+
+
+
+
Properties
+
+
+
_entries
+ - private Object[]
+
+
+
+ Array of request/response objects indexed chronologically.
+
+
+
+
+
+
+
+
+
+
NAME
+ - static final String
+
+
+
+
+
+
+
+
+
+
NS
+ - static final String
+
+
+
+ The namespace for the plugin. This will be the property on the host which
+references the plugin instance.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Properties inherited from Attribute:
+
+
+
+
+
+
+
+
Properties inherited from Base:
+
+
+
+
+
+
+
+
+
Methods
+
+
+
+
+
+ protected
+
+
+ void
+ _defAddFn
+ (
+
+
+ e
+
+
+ )
+
+
+
+ Adds entry to cache.
+
+
+
+
+
+ - Parameters:
+ -
+
e
+ <Event.Facade>
+
+ Event Facade with the following properties:
+
+- entry (Object)
- The cached entry.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ protected
+
+
+ void
+ _defFlushFn
+ (
+
+
+ e
+
+
+ )
+
+
+
+ Flushes cache.
+
+
+
+
+
+ - Parameters:
+ -
+
e
+ <Event.Facade>
+
+ Event Facade object.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ protected
+
+
+ Boolean
+ _isMatch
+ (
+
+
+ request
+
+
+ ,
+ entry
+
+
+ )
+
+
+
+ Default overridable method compares current request with given cache entry.
+Returns true if current request matches the cached request, otherwise
+false. Implementers should override this method to customize the
+cache-matching algorithm.
+
+
+
+
+
+ - Parameters:
+ -
+
request
+ <Object>
+
+ Request object.
+
+ -
+
entry
+ <Object>
+
+ Cached entry.
+
+
+
+
+ - Returns:
+
+ Boolean
+
+ - True if current request matches given cached request, false otherwise.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ void
+ add
+ (
+
+
+ request
+
+
+ ,
+ response
+
+
+ ,
+ payload
+
+
+ )
+
+
+
+ Adds a new entry to the cache of the format
+{request:request, response:response, payload:payload}.
+If cache is full, evicts the stalest entry before adding the new one.
+
+
+
+
+
+ - Parameters:
+ -
+
request
+ <Object>
+
+ Request value.
+
+ -
+
response
+ <Object>
+
+ Response value.
+
+ -
+
payload
+ <Object>
+
+ (optional) Arbitrary data payload.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ private
+
+
+ void
+ destructor
+ (
+ )
+
+
+
+ Internal destroy() handler.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ void
+ flush
+ (
+ )
+
+
+
+ Flushes cache.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ private
+
+
+ void
+ initializer
+ (
+
+
+ config
+
+
+ )
+
+
+
+ Internal init() handler.
+
+
+
+
+
+ - Parameters:
+ -
+
config
+ <Object>
+
+ Config object.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Object
+ retrieve
+ (
+
+
+ request
+
+
+ )
+
+
+
+ Retrieves cached entry for given request, if available, and refreshes
+entry in the cache. Returns null if there is no cache match.
+
+
+
+
+
+ - Parameters:
+ -
+
request
+ <Object>
+
+ Request object.
+
+
+
+
+ - Returns:
+
+ Object
+
+ - Cached entry object with the properties request, response, and payload, or null.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Methods inherited from EventTarget:
+
+
+
+ _getType,
+
+
+ _parseType,
+
+
+ addTarget,
+
+
+ after,
+
+
+ before,
+
+
+ bubble,
+
+
+ detach,
+
+
+ detachAll,
+
+
+ fire,
+
+
+ getEvent,
+
+
+ on,
+
+
+ publish,
+
+
+ removeTarget,
+
+
+ subscribe,
+
+
+ unsubscribe,
+
+
+ unsubscribeAll
+
+
+
+
+
+
Methods inherited from Attribute:
+
+
+
+ _addAttrs,
+
+
+ _addLazyAttr,
+
+
+ _defAttrChangeFn,
+
+
+ _fireAttrChange,
+
+
+ _getAttr,
+
+
+ _getAttrInitVal,
+
+
+ _getAttrs,
+
+
+ _getStateVal,
+
+
+ _isLazyAttr,
+
+
+ _normAttrVals,
+
+
+ _protectAttrs,
+
+
+ _set,
+
+
+ _setAttr,
+
+
+ _setAttrs,
+
+
+ _setAttrVal,
+
+
+ _setStateVal,
+
+
+ addAttr,
+
+
+ addAttrs,
+
+
+ attrAdded,
+
+
+ get,
+
+
+ getAttrs,
+
+
+ modifyAttr,
+
+
+ removeAttr,
+
+
+ reset,
+
+
+ set,
+
+
+ setAttrs
+
+
+
+
+
+
Methods inherited from Base:
+
+
+
+ _aggregateAttrs,
+
+
+ _defDestroyFn,
+
+
+ _defInitFn,
+
+
+ _destroyHierarchy,
+
+
+ _filterAttrCfs,
+
+
+ _getAttrCfgs,
+
+
+ _getClasses,
+
+
+ _initHierarchy,
+
+
+ _initHierarchyData,
+
+
+ destroy,
+
+
+ init,
+
+
+ toString
+
+
+
+
+
+
+
+
+
+
+
Events
+
+
+
+
+
+
+
+
+ add
+
+ (
+
+
+ e
+
+
+ )
+
+
+
+
+ Fired when an entry is added.
+
+
+
+
+
+
+ - Parameters:
+ -
+
e
+ <Event.Facade>
+
+ Event Facade with the following properties:
+
+- entry (Object)
- The cached entry.
+
+
+
+
+
+
+ Preventable: This event is preventable by method e.preventDefault(). The default function executed by this event is _defAddFn.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ entriesChange
+
+ (
+
+
+ event
+
+
+ )
+
+
+
+
+ Fires when the value for the configuration attribute 'entries' 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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ flush
+
+ (
+
+
+ e
+
+
+ )
+
+
+
+
+ Fired when the cache is flushed.
+
+
+
+
+
+
+ - Parameters:
+ -
+
e
+ <Event.Facade>
+
+ Event Facade object.
+
+
+
+
+
+ Preventable: This event is preventable by method e.preventDefault(). The default function executed by this event is _defFlushFn.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ request
+
+ (
+
+
+ e
+
+
+ )
+
+
+
+
+ Fired when an entry is requested from the cache.
+
+
+
+
+
+
+ - Parameters:
+ -
+
e
+ <Event.Facade>
+
+ Event Facade with the following properties:
+
+- request (Object)
- The request object.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ retrieve
+
+ (
+
+
+ e
+
+
+ )
+
+
+
+
+ Fired when an entry is retrieved from the cache.
+
+
+
+
+
+
+ - Parameters:
+ -
+
e
+ <Event.Facade>
+
+ Event Facade with the following properties:
+
+- entry (Object)
- The retrieved entry.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ sizeChange
+
+ (
+
+
+ event
+
+
+ )
+
+
+
+
+ Fires when the value for the configuration attribute 'size' 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
+
+ (
+
+
+ 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:
+
+
+
+
+
+
+
+
+
Configuration Attributes
+
+
+
+
max
+ - Number
+
+
+
+ Maximum number of entries the Cache can hold.
+Set to 0 to turn off caching.
+
+
+
+
+
+ Default Value: 0
+
+
+
+
+
+
size
+ - Number
+
+
+
+ Number of entries currently cached.
+
+
+
+
+
+
+
+
+
+
+
+ Validate uniqueness of stored keys. Default is false and
+is more performant.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Configuration attributes inherited from Plugin.Base:
+
+
+
+
+
+
+