vj12
clone your own copy | download snapshot

Snapshots | iceberg

Inside this repository

cache.js
application/javascript

Download raw (478 bytes)

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() {}
  });
};