diff options
Diffstat (limited to 'app/assets/javascripts/lib')
-rw-r--r-- | app/assets/javascripts/lib/utils/ajax_cache.js | 18 | ||||
-rw-r--r-- | app/assets/javascripts/lib/utils/cache.js | 19 |
2 files changed, 23 insertions, 14 deletions
diff --git a/app/assets/javascripts/lib/utils/ajax_cache.js b/app/assets/javascripts/lib/utils/ajax_cache.js index cf030d613df..f1fe95e12e8 100644 --- a/app/assets/javascripts/lib/utils/ajax_cache.js +++ b/app/assets/javascripts/lib/utils/ajax_cache.js @@ -1,21 +1,11 @@ -class AjaxCache { +import Cache from './cache'; + +class AjaxCache extends Cache { constructor() { - this.internalStorage = { }; + super(); this.pendingRequests = { }; } - get(endpoint) { - return this.internalStorage[endpoint]; - } - - hasData(endpoint) { - return Object.prototype.hasOwnProperty.call(this.internalStorage, endpoint); - } - - remove(endpoint) { - delete this.internalStorage[endpoint]; - } - retrieve(endpoint) { if (this.hasData(endpoint)) { return Promise.resolve(this.get(endpoint)); diff --git a/app/assets/javascripts/lib/utils/cache.js b/app/assets/javascripts/lib/utils/cache.js new file mode 100644 index 00000000000..3141f1eeafc --- /dev/null +++ b/app/assets/javascripts/lib/utils/cache.js @@ -0,0 +1,19 @@ +class Cache { + constructor() { + this.internalStorage = { }; + } + + get(key) { + return this.internalStorage[key]; + } + + hasData(key) { + return Object.prototype.hasOwnProperty.call(this.internalStorage, key); + } + + remove(key) { + delete this.internalStorage[key]; + } +} + +export default Cache; |