index.js 797 Bytes
let DbTypes = {
    DEF: 'default'
};

/**
 * 缓存适配器
 */
class CacheAdapter {
    constructor(dbName) {
        this.dbName = dbName;
        if (dbName === DbTypes.DEF) {
            let DbType = require('./defaultCache');

            this.db = new DbType();
        }
    }
    get(key) {
        if (this.dbName === DbTypes.DEF) {
            return this.db.get(key);
        }
    }
    remove(key) {
        if (this.dbName === DbTypes.DEF) {
            return this.db.remove(key);
        }
    }
    set(key, value) {
        if (this.dbName === DbTypes.DEF) {
            return this.db.set(key, value);
        }
    }
    clear() {
        if (this.dbName === DbTypes.DEF) {
            return this.db.clear();
        }
    }
}

export default new CacheAdapter(DbTypes.DEF);