Add scripts to create myops-getqueryview:
[myops.git] / web / query / vendor / couchapp / lib / cache.js
diff --git a/web/query/vendor/couchapp/lib/cache.js b/web/query/vendor/couchapp/lib/cache.js
new file mode 100644 (file)
index 0000000..58b2e33
--- /dev/null
@@ -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