keeweb/app/scripts/storage/impl/storage-cache.js

33 lines
701 B
JavaScript
Raw Normal View History

2019-09-15 14:16:32 +02:00
import { IoBrowserCache } from 'storage/io-browser-cache';
import { StorageBase } from 'storage/storage-base';
2015-11-07 20:02:45 +01:00
2017-01-31 07:50:28 +01:00
const StorageCache = StorageBase.extend({
2015-11-07 20:02:45 +01:00
name: 'cache',
2017-02-19 18:51:52 +01:00
enabled: IoBrowserCache.enabled,
2016-03-13 17:08:25 +01:00
system: true,
2015-11-07 20:02:45 +01:00
2017-02-19 18:51:52 +01:00
io: null,
2015-11-07 20:02:45 +01:00
2017-02-19 18:51:52 +01:00
init() {
StorageBase.prototype.init.call(this);
this.io = new IoBrowserCache({
cacheName: 'FilesCache',
logger: this.logger
});
2015-11-07 20:02:45 +01:00
},
2017-02-19 18:51:52 +01:00
save(id, opts, data, callback) {
this.io.save(id, data, callback);
2015-11-07 20:02:45 +01:00
},
2017-02-19 18:51:52 +01:00
load(id, opts, callback) {
this.io.load(id, callback);
2015-11-07 20:02:45 +01:00
},
2017-02-19 18:51:52 +01:00
remove(id, opts, callback) {
this.io.remove(id, callback);
2015-11-07 20:02:45 +01:00
}
2016-03-27 09:06:23 +02:00
});
2015-11-07 20:02:45 +01:00
2019-09-15 14:16:32 +02:00
export { StorageCache };