index.js
797 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
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);