Skip to content

Instantly share code, notes, and snippets.

@joeauty
Created June 11, 2011 09:10
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save joeauty/1020395 to your computer and use it in GitHub Desktop.
this.cacheset = function(owner, datarequest, object) {
// assigns object to webkitcache
YUI().use('cache', 'node', function(Y) {
if (!webkit.wkcache) {
webkit.wkcache = new Y.Cache({max:10});
}
if (Y.one('#' + object)) {
// cache request sent as dom ID rather than node object
object = Y.one('#' + object);
}
webkit.wkcache.add(owner + '_' + datarequest, {
id:object.get('id'),
innerHTML:object.get('innerHTML')
});
})
}
this.cacheget = function(owner, datarequest) {
// checks to see if cache for datarequest exists
if (webkit.wkcache && webkit.wkcache.retrieve(owner + '_' + datarequest)) {
return true;
}
return false;
}
this.cacheoutput = function(owner, datarequest, object) {
var cacheObj = webkit.wkcache.retrieve(owner + '_' + datarequest);
webkit.Y.one('#' + cacheObj.response.id).set('innerHTML', cacheObj.response.innerHTML);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment