// Compiled by ClojureScript 0.0-2138
goog.provide('lt.objs.cache');
goog.require('cljs.core');
goog.require('cljs.reader');
goog.require('cljs.reader');
goog.require('lt.objs.files');
goog.require('lt.objs.files');
goog.require('lt.object');
goog.require('lt.object');
lt.objs.cache.cache_path = lt.objs.files.lt_user_dir.call(null,"ltcache");
lt.objs.cache.settings_path = [cljs.core.str(lt.objs.files.lt_user_dir.call(null,"ltcache/default.clj"))].join('');
lt.objs.cache.settings = cljs.core.atom.call(null,cljs.core.PersistentArrayMap.EMPTY);
lt.objs.cache.on_disk = (function on_disk(cb){return lt.objs.files.open.call(null,lt.objs.cache.settings_path,(function (data){if(!(cljs.core.empty_QMARK_.call(null,data)))
{return cb.call(null,cljs.reader.read_string.call(null,new cljs.core.Keyword(null,"content","content",1965434859).cljs$core$IFn$_invoke$arity$1(data)));
} else
{return cb.call(null,cljs.core.PersistentArrayMap.EMPTY);
}
}));
});
lt.objs.cache.save = (function save(){return lt.objs.cache.on_disk.call(null,(function (data){var updated = cljs.core.merge.call(null,data,cljs.core.deref.call(null,lt.objs.cache.settings));lt.objs.files.save.call(null,lt.objs.cache.settings_path,cljs.core.pr_str.call(null,updated));
return cljs.core.reset_BANG_.call(null,lt.objs.cache.settings,updated);
}));
});
lt.objs.cache.fetch = (function fetch__$1(k){return cljs.core.deref.call(null,lt.objs.cache.settings).call(null,k);
});
lt.objs.cache.store_BANG_ = (function store_BANG_(k,v){cljs.core.swap_BANG_.call(null,lt.objs.cache.settings,cljs.core.assoc,k,v);
return lt.objs.cache.save.call(null);
});
lt.objs.cache.store_in_BANG_ = (function store_in_BANG_(ks,v){cljs.core.swap_BANG_.call(null,lt.objs.cache.settings,cljs.core.assoc_in,ks,v);
return lt.objs.cache.save.call(null);
});
lt.objs.cache.init = (function init(){return lt.objs.cache.on_disk.call(null,(function (setts){return cljs.core.swap_BANG_.call(null,lt.objs.cache.settings,cljs.core.merge,setts);
}));
});
lt.objs.cache.__BEH__init = (function __BEH__init(this$){if(cljs.core.truth_(lt.objs.files.exists_QMARK_.call(null,lt.objs.cache.cache_path)))
{} else
{lt.objs.files.mkdir.call(null,lt.objs.cache.cache_path);
}
return lt.objs.cache.init.call(null);
});
lt.object.behavior_STAR_.call(null,new cljs.core.Keyword("lt.objs.cache","init","lt.objs.cache/init",4024902129),new cljs.core.Keyword(null,"reaction","reaction",4441361819),lt.objs.cache.__BEH__init,new cljs.core.Keyword(null,"triggers","triggers",2516997421),new cljs.core.PersistentHashSet(null, new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"deploy","deploy",3973538905),null], null), null));
lt.object.tag_behaviors.call(null,new cljs.core.Keyword(null,"app","app",1014001043),new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword("lt.objs.cache","init","lt.objs.cache/init",4024902129)], null));
