/* * Copyright (c) 2019 Digital Bazaar, Inc. All rights reserved. */ 'use strict'; const LRU = require('lru-cache'); const MAX_ACTIVE_CONTEXTS = 10; module.exports = class ResolvedContext { /** * Creates a ResolvedContext. * * @param document the context document. */ constructor({document}) { this.document = document; // TODO: enable customization of processed context cache // TODO: limit based on size of processed contexts vs. number of them this.cache = new LRU({max: MAX_ACTIVE_CONTEXTS}); } getProcessed(activeCtx) { return this.cache.get(activeCtx); } setProcessed(activeCtx, processedCtx) { this.cache.set(activeCtx, processedCtx); } };