
class CacheManager{

    constructor(){
        this.map = new Map();
        
    }



    /**
     * 缓存obj
     * @param {string} key 
     * @param {object} obj 
     */
    setObject(key, obj){
        this.map.set(key, obj);
    }

    /**
     * 返回缓存的obj
     * @param {string} key
     *  
     */
    getObject(key){
        if(this.getObjectIsCache(key)){
            return this.map.get(key);
        }else{
            return null;
        }
    }


    /**
     * key是否有缓存
     * @param {string} key 
     */
    getObjectIsCache(key){
        let value = this.map.get(key);
        if(value === undefined){
            console.log("this obj is not cache:", key);
            return false;
        }
        return true;
    }

}
module.exports = new CacheManager();