X-Git-Url: http://git.onelab.eu/?p=myops.git;a=blobdiff_plain;f=web%2Fquery%2Fvendor%2Fcouchapp%2Flib%2Fcache.js;fp=web%2Fquery%2Fvendor%2Fcouchapp%2Flib%2Fcache.js;h=58b2e33f99ad2c46744dfca12c35ec283f9696b2;hp=0000000000000000000000000000000000000000;hb=85070b3d456667f238051af1a2f1f2a0c12300ab;hpb=607f0e13927eb18075c375fa9ba5527da4fcbb44 diff --git a/web/query/vendor/couchapp/lib/cache.js b/web/query/vendor/couchapp/lib/cache.js new file mode 100644 index 0000000..58b2e33 --- /dev/null +++ b/web/query/vendor/couchapp/lib/cache.js @@ -0,0 +1,25 @@ +exports.get = function(db, docid, setFun, getFun) { + db.openDoc(docid, { + success : function(doc) { + getFun(doc.cache); + }, + error : function() { + setFun(function(cache) { + db.saveDoc({ + _id : docid, + cache : cache + }); + getFun(cache); + }); + } + }); +}; + +exports.clear = function(db, docid) { + db.openDoc(docid, { + success : function(doc) { + db.removeDoc(doc); + }, + error : function() {} + }); +}; \ No newline at end of file