From 8fc9985b6278cc97c8d1446f59914e09a5b23e0f Mon Sep 17 00:00:00 2001 From: Dave Longley Date: Wed, 21 Jan 2026 16:47:19 -0500 Subject: [PATCH 1/2] Allow passing external lru cache instance. --- CHANGELOG.md | 10 ++++++++++ lib/CachedResolver.js | 16 ++++++++++++---- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9729181..0db39c4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,15 @@ # did-io ChangeLog +## 2.1.0 - 2026-mm-dd + +### Added +- Add option to allow a compatible external cache instance to be passed to + passed to `CachedResolver`. The cache instance must minimally support + `memoize()` with a signature that matches `@digitalbazaar/lru-memoize@4`. + This option allows applications to use different versions of the + cache with their own initialization code, provided that it maintains + the necessary interface. + ## 2.0.0 - 2022-06-02 ### Changed diff --git a/lib/CachedResolver.js b/lib/CachedResolver.js index bfd0673..c1bcf65 100644 --- a/lib/CachedResolver.js +++ b/lib/CachedResolver.js @@ -1,5 +1,5 @@ /*! - * Copyright (c) 2021 Digital Bazaar, Inc. All rights reserved. + * Copyright (c) 2021-2026 Digital Bazaar, Inc. All rights reserved. */ import {parseDid} from './did-io.js'; import {LruCache} from '@digitalbazaar/lru-memoize'; @@ -7,6 +7,10 @@ import {LruCache} from '@digitalbazaar/lru-memoize'; export class CachedResolver { /** * @param {object} [options={}] - Options hashmap. + * @param {object} [options.cache] - The cache instance to use; it must have + * an interface compatible with `@digitalbazaar/lru-memoize`'s `LruCache` + * object, minimally implementing `memoize()`; if this option is used, + * then all other options are ignored. * @param {number} [options.max=100] - Max number of items in the cache. * @param {number} [options.maxAge=5000] - Max age of a cache item, in ms. * @param {boolean} [options.updateAgeOnGet=false] - When using time-expiring @@ -15,9 +19,13 @@ export class CachedResolver { * cache, thereby extending the expiration date of the entry. * @param {object} [options.cacheOptions] - Additional `lru-cache` options. */ - constructor({max = 100, maxAge = 5000, updateAgeOnGet = false, - ...cacheOptions} = {}) { - this._cache = new LruCache({max, maxAge, updateAgeOnGet, ...cacheOptions}); + constructor({ + cache, max = 100, maxAge = 5000, updateAgeOnGet = false, + ...cacheOptions + } = {}) { + this._cache = cache ?? new LruCache({ + max, maxAge, updateAgeOnGet, ...cacheOptions + }); this._methods = new Map(); } From 7feacd8c14f8049e4a00d7f513a3615c1049d157 Mon Sep 17 00:00:00 2001 From: Dave Longley Date: Wed, 21 Jan 2026 16:50:44 -0500 Subject: [PATCH 2/2] Update github actions. --- .github/workflows/main.yml | 85 +++++++++++++++++++------------------- 1 file changed, 43 insertions(+), 42 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7a0d85f..917640b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -8,66 +8,67 @@ jobs: timeout-minutes: 10 strategy: matrix: - node-version: [16.x] + node-version: [24.x] steps: - - uses: actions/checkout@v2 - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v1 - with: - node-version: ${{ matrix.node-version }} - - run: npm install - - name: Run eslint - run: npm run lint + - uses: actions/checkout@v4 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node-version }} + - run: npm install + - name: Run eslint + run: npm run lint test-node: needs: [lint] runs-on: ubuntu-latest timeout-minutes: 10 strategy: matrix: - node-version: [14.x, 16.x, 18.x] + node-version: [22.x, 24.x] steps: - - uses: actions/checkout@v2 - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v1 - with: - node-version: ${{ matrix.node-version }} - - run: npm install - - name: Run test with Node.js ${{ matrix.node-version }} - run: npm run test-node + - uses: actions/checkout@v4 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node-version }} + - run: npm install + - name: Run test with Node.js ${{ matrix.node-version }} + run: npm run test-node test-karma: needs: [lint] runs-on: ubuntu-latest timeout-minutes: 10 strategy: matrix: - node-version: [16.x] + node-version: [24.x] steps: - - uses: actions/checkout@v2 - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v1 - with: - node-version: ${{ matrix.node-version }} - - run: npm install - - name: Run karma tests - run: npm run test-karma + - uses: actions/checkout@v4 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node-version }} + - run: npm install + - name: Run karma tests + run: npm run test-karma coverage: needs: [test-node, test-karma] - runs-on: ubuntu-latest timeout-minutes: 10 + runs-on: ubuntu-latest strategy: matrix: - node-version: [16.x] + node-version: [24.x] steps: - - uses: actions/checkout@v2 - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v1 - with: - node-version: ${{ matrix.node-version }} - - run: npm install - - name: Generate coverage report - run: npm run coverage-ci - - name: Upload coverage to Codecov - uses: codecov/codecov-action@v2 - with: - file: ./coverage/lcov.info - fail_ci_if_error: true + - uses: actions/checkout@v4 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node-version }} + - run: npm install + - name: Generate coverage report + run: npm run coverage-ci + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v4 + with: + file: ./test/coverage/lcov.info + fail_ci_if_error: true + token: ${{ secrets.CODECOV_TOKEN }}