Permalink
Browse files

added microcache in tquery.core

  • Loading branch information...
1 parent 2e94d2b commit 19d141ee3c9af1066574145bfc1c728629c7e914 @jeromeetienne committed Mar 3, 2013
Showing with 21 additions and 0 deletions.
  1. +21 −0 js/tquery.core.js
View
21 js/tquery.core.js
@@ -387,3 +387,24 @@ tQuery.MicroeventMixin = function(destObj){
}
};
+/**
+ * https://github.com/jeromeetienne/MicroCache.js
+*/
+tQuery.MicroCache = function(){
+ var _values = {};
+ return {
+ get : function(key){ return _values[key]; },
+ contains: function(key){ return key in _values; },
+ remove : function(key){ delete _values[key]; },
+ set : function(key, value){ _values[key] = value;},
+ values : function(){ return _values; },
+ getSet : function(key, value){
+ if( !this.contains(key) ){
+ this.set(key, typeof value == 'function' ? value() : value )
+ }
+ return this.get(key);
+ }
+ }
+}
+
+

0 comments on commit 19d141e

Please sign in to comment.