实现代码如下:

var DataCache = function(){
if(!(this instanceof DataCache)){
return new DataCache();
}
this.id = 0;
this.caches = {};
};
DataCache.prototype = {
add : function(val){
val = val || null;
key = "dc_" + this.id;

this.caches[key] = val;
return key;
},
remove : function(key){
delete this.caches[key];
},
get : function(key){
return this.caches[key];
},
set : function(key,val){
this.caches[key] = val;
}
};

以上就是【一个简单的JavaScript数据缓存系统实现代码】的全部内容了,欢迎留言评论进行交流!

赞(0) 踩(0)

与本文相关的软件

发表我的评论

最新评论

  1. 暂无评论