datasource-cache-debug.js revision 2d05ae30a932507d8c42cef6b78b46e0876a5669
/**
* Extends DataSource with caching functionality.
*
* @module datasource
*/
/**
* Adds cacheability to the YUI DataSource utility.
* @class DataSourceCache
* @extends Cache
*/
var DataSourceCache = function() {
};
Y.mix(DataSourceCache, {
/**
* The namespace for the plugin. This will be the property on the host which
* references the plugin instance.
*
* @property NS
* @type String
* @static
* @final
* @value "cache"
*/
NS: "cache",
/**
* Class name.
*
* @property NAME
* @type String
* @static
* @final
* @value "DataSourceCache"
*/
NAME: "DataSourceCache",
/////////////////////////////////////////////////////////////////////////////
//
// DataSourceCache Attributes
//
/////////////////////////////////////////////////////////////////////////////
ATTRS: {
}
});
/**
* @method initializer
* @description Internal init() handler.
* @private
*/
initializer: function(config) {
},
/**
* First look for cached response, then send request to live data.
*
* @method _beforeDefRequestFn
* @param e {Event.Facade} Event Facade.
* @param o {Object} Object with the following properties:
* <dl>
* <dt>tId (Number)</dt> <dd>Unique transaction ID.</dd>
* <dt>request (Object)</dt> <dd>The request.</dd>
* <dt>callback (Object)</dt> <dd>The callback object.</dd>
* </dl>
* @protected
*/
_beforeDefRequestFn: function(e, o) {
// Is response already in the Cache?
}
},
/**
* Adds data to cache before returning data.
*
* @method _beforeResponse
* @param e {Event.Facade} Event Facade.
* @param o {Object} Object with the following properties:
* <dl>
* <dt>tId (Number)</dt> <dd>Unique transaction ID.</dd>
* <dt>request (Object)</dt> <dd>The request.</dd>
* <dt>callback (Object)</dt> <dd>The callback object.</dd>
* <dt>data (Object)</dt> <dd>Raw data.</dd>
* <dt>results (Object)</dt> <dd>Parsed results.</dd>
* <dt>meta (Object)</dt> <dd>Parsed meta data.</dd>
* </dl>
* @protected
*/
_beforeDefResponseFn: function(e, o) {
// Add to Cache before returning
}
});
Y.namespace('plugin');