mirror of
https://github.com/idanoo/GoScrobble.git
synced 2024-11-24 17:35:16 +00:00
29 lines
717 B
JavaScript
29 lines
717 B
JavaScript
|
"use strict";
|
||
|
|
||
|
Object.defineProperty(exports, "__esModule", {
|
||
|
value: true
|
||
|
});
|
||
|
exports.default = void 0;
|
||
|
// Used https://github.com/thinkloop/multi-key-cache as inspiration
|
||
|
var multiKeyStore = {
|
||
|
set: function set(cache, key1, key2, value) {
|
||
|
var subCache = cache.get(key1);
|
||
|
|
||
|
if (!subCache) {
|
||
|
subCache = new Map();
|
||
|
cache.set(key1, subCache);
|
||
|
}
|
||
|
|
||
|
subCache.set(key2, value);
|
||
|
},
|
||
|
get: function get(cache, key1, key2) {
|
||
|
var subCache = cache.get(key1);
|
||
|
return subCache ? subCache.get(key2) : undefined;
|
||
|
},
|
||
|
delete: function _delete(cache, key1, key2) {
|
||
|
var subCache = cache.get(key1);
|
||
|
subCache.delete(key2);
|
||
|
}
|
||
|
};
|
||
|
var _default = multiKeyStore;
|
||
|
exports.default = _default;
|