@azure/cosmos
Version:
Microsoft Azure Cosmos DB Service Node.js SDK for NOSQL API
35 lines • 1.13 kB
JavaScript
;
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
Object.defineProperty(exports, "__esModule", { value: true });
exports.KeyEncryptionKeyCache = void 0;
const KeyEncryptionKey_js_1 = require("../KeyEncryptionKey.js");
/**
* The cache used to store the key encryption keys.
* see {@link KeyEncryptionKey}
* @hidden
*/
class KeyEncryptionKeyCache {
// key is JSON.stringify([name, path])
cache;
constructor() {
this.cache = new Map();
}
getOrCreate(name, path, keyStoreProvider) {
const key = JSON.stringify([name, path]);
let keyEncryptionKey = this.get(key);
if (!keyEncryptionKey) {
keyEncryptionKey = new KeyEncryptionKey_js_1.KeyEncryptionKey(name, path, keyStoreProvider);
this.set(key, keyEncryptionKey);
}
return keyEncryptionKey;
}
get(key) {
return this.cache.get(key);
}
set(key, keyEncryptionKey) {
this.cache.set(key, keyEncryptionKey);
}
}
exports.KeyEncryptionKeyCache = KeyEncryptionKeyCache;
//# sourceMappingURL=KeyEncryptionKeyCache.js.map