感觉牛逼的还是接口设计的实现, 纵观下来,对于cacheFactory 的实现
主要提供两个方法
// 存储数据的地方
var caches = {};
function cacheFactory(cacheId){
//
return caches[cacheId] = {
//
put:function(key,value){
},
get:function(key){
},
remove:function(key){
},
removeAll:function(){
},
destroy:function(){
},
info:function(){
}
}
}
cacheFactory.info = function(){}
cacheFactory.get = function(){}
对于 templateCache 缓存的实现,就是依赖 cacheFactory 实现的
function $TemplateCacheProvider(){
this.$get = ['$cacheFactory',function($cacheFactory){
return $cacheFactory('templates');
}]
}