datasource-cache.js revision 1bc27dc58fd882eb8902cdefa2dde4a8ee2a5bbd
/**
* Extends DataSource.Base with caching functionality.
*
* @module datasource-cache
* @requires datasource-base,cache
* @title DataSource Cache Extension
*/
/**
* Adds cacheability to the YUI DataSource utility.
* @class Cacheable
*/
Cacheable = function() {};
/////////////////////////////////////////////////////////////////////////////
//
// DataSource.Base Attributes
//
/////////////////////////////////////////////////////////////////////////////
/**
* Instance of Y.Cache. Caching is useful to reduce the number of server
* connections. Recommended only for data sources that return comprehensive
* results for queries or when stale data is not an issue.
*
* @attribute cache
* @type Y.Cache
* @default null
*/
cache: {
value: null,
},
var i=0,
handlers = this._cacheHandlers;
// Enabling...
if(value !== null) {
// for the first time
if(handlers === null) {
handlers = [];
this._cacheHandlers = handlers;
}
}
// Disabling
else if(handlers !== null){
for(;i<handlers; i++) {
}
this._cacheHandlers = null;
}
//TODO: Handle the destroy() case
}
}
};
/**
* Internal reference to AOP subscriptions, for detaching.
*
* @property _cacheHandlers
* @private
* @type Array
*/
_cacheHandlers: null,
/**
* First look for cached response, then send request to live data.
*
* @method _beforeSendRequest
* @protected
* @param request {MIXED} Request.
* @param callback {Object} Callback object.
*/
// Is response already in the Cache?
}
},
/**
* Adds data to cache before returning data.
*
* @method _beforeReturnData
* @protected
* @param tId {Number} Transaction ID.
* @param request {MIXED} Request.
* @param callback {Object} Callback object.
* @param response {MIXED} Raw data response.
*/
// Add to Cache before returning
if(this.get("cache")) {
}
}
};
dynamic: false
});