mirror of
https://github.com/JonnyBro/JaBa.git
synced 2024-12-29 06:43:02 +05:00
feat: added cache adapter
This commit is contained in:
parent
b26222a947
commit
ac461a104d
2 changed files with 33 additions and 0 deletions
9
src/adapters/cache/ICacheAdapter.js
vendored
Normal file
9
src/adapters/cache/ICacheAdapter.js
vendored
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
export default class ICacheAdapter {
|
||||||
|
get() {}
|
||||||
|
|
||||||
|
set() {}
|
||||||
|
|
||||||
|
clear() {}
|
||||||
|
|
||||||
|
delete() {}
|
||||||
|
}
|
24
src/adapters/cache/MapCache.js
vendored
Normal file
24
src/adapters/cache/MapCache.js
vendored
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
import ICacheAdapter from "./ICacheAdapter";
|
||||||
|
|
||||||
|
export default class MapCache extends ICacheAdapter {
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
this.store = new Map();
|
||||||
|
}
|
||||||
|
|
||||||
|
get(key) {
|
||||||
|
return this.store.get(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
set(key, value) {
|
||||||
|
this.store.set(key, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
clear() {
|
||||||
|
this.store.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
delete(key) {
|
||||||
|
this.store.delete(key);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue