diff --git a/CHANGELOG.md b/CHANGELOG.md index d898bd1..90a1655 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) +## [7.0.5] - 2025-11-14 + +### Changed + +- Switch from redis to ioredis + ## [7.0.0-beta] - 2025-11-14 ### Changed diff --git a/package.json b/package.json index 5147e18..71d25b9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "lambda-essentials-ts", - "version": "7.0.4", + "version": "7.0.5", "description": "A selection of the finest modules supporting authorization, API routing, error handling, logging and sending HTTP requests.", "main": "lib/index.js", "private": false, @@ -51,8 +51,7 @@ "prettier": "^2.8.8", "ts-jest": "^29.4.6", "ts-node": "^10.9.2", - "typescript": "^5.9.3", - "redis": "^5.10.0" + "typescript": "^5.9.3" }, "eslintConfig": { "extends": "cimpress-atsquad" @@ -80,6 +79,7 @@ "node": ">=20.0.0" }, "peerDependencies": { - "newrelic": "^12.0.0" + "newrelic": "^12.0.0", + "ioredis": "^5.9.1" } } diff --git a/src/httpClient/redisStorage.ts b/src/httpClient/redisStorage.ts index b819dff..d785c56 100644 --- a/src/httpClient/redisStorage.ts +++ b/src/httpClient/redisStorage.ts @@ -7,26 +7,19 @@ const MIN_TTL = 60000; export default function createRedisStorage(redisEndpoint: string) { // eslint-disable-next-line import/no-extraneous-dependencies - const redis = require('redis'); + const Redis = require('ioredis'); - const client = redis.createClient({ url: redisEndpoint }); + const client = new Redis(redisEndpoint); // source https://axios-cache-interceptor.js.org/guide/storages#node-redis-storage return buildStorage({ async find(key) { - if (!client.isReady) { - await client.connect(); - } const result = await client.get(`${KEY_PREFIX}${key}`); return result ? (JSON.parse(result) as StorageValue) : undefined; }, // eslint-disable-next-line complexity async set(key, value, req) { - if (!client.isReady) { - await client.connect(); - } - await client.set(`${KEY_PREFIX}${key}`, JSON.stringify(value), { PXAT: // We don't want to keep indefinitely values in the storage if @@ -45,9 +38,6 @@ export default function createRedisStorage(redisEndpoint: string) { }, async remove(key) { - if (!client.isReady) { - await client.connect(); - } await client.del(`${KEY_PREFIX}${key}`); }, }); diff --git a/yarn.lock b/yarn.lock index 9407fe6..d1667d6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1128,33 +1128,6 @@ "@nodelib/fs.scandir" "2.1.5" fastq "^1.6.0" -"@redis/bloom@5.10.0": - version "5.10.0" - resolved "https://registry.yarnpkg.com/@redis/bloom/-/bloom-5.10.0.tgz#1079373583b82a8b61b0d3721755245686b4a602" - integrity sha512-doIF37ob+l47n0rkpRNgU8n4iacBlKM9xLiP1LtTZTvz8TloJB8qx/MgvhMhKdYG+CvCY2aPBnN2706izFn/4A== - -"@redis/client@5.10.0": - version "5.10.0" - resolved "https://registry.yarnpkg.com/@redis/client/-/client-5.10.0.tgz#621d5de1898a4f2c3a813769779ca5902ef9d57a" - integrity sha512-JXmM4XCoso6C75Mr3lhKA3eNxSzkYi3nCzxDIKY+YOszYsJjuKbFgVtguVPbLMOttN4iu2fXoc2BGhdnYhIOxA== - dependencies: - cluster-key-slot "1.1.2" - -"@redis/json@5.10.0": - version "5.10.0" - resolved "https://registry.yarnpkg.com/@redis/json/-/json-5.10.0.tgz#a550a7859c3cbae45535aad157fcaa8e6bd3e7d3" - integrity sha512-B2G8XlOmTPUuZtD44EMGbtoepQG34RCDXLZbjrtON1Djet0t5Ri7/YPXvL9aomXqP8lLTreaprtyLKF4tmXEEA== - -"@redis/search@5.10.0": - version "5.10.0" - resolved "https://registry.yarnpkg.com/@redis/search/-/search-5.10.0.tgz#587851479c6abb9b40b31ab9b31c234db7a04919" - integrity sha512-3SVcPswoSfp2HnmWbAGUzlbUPn7fOohVu2weUQ0S+EMiQi8jwjL+aN2p6V3TI65eNfVsJ8vyPvqWklm6H6esmg== - -"@redis/time-series@5.10.0": - version "5.10.0" - resolved "https://registry.yarnpkg.com/@redis/time-series/-/time-series-5.10.0.tgz#9c7de35fe023e36233fba5c8478ce25832ead64c" - integrity sha512-cPkpddXH5kc/SdRhF0YG0qtjL+noqFT0AcHbQ6axhsPsO7iqPi1cjxgdkE9TNeKiBUUdCaU1DbqkR/LzbzPBhg== - "@rtsao/scc@^1.1.0": version "1.1.0" resolved "https://registry.yarnpkg.com/@rtsao/scc/-/scc-1.1.0.tgz#927dd2fae9bc3361403ac2c7a00c32ddce9ad7e8" @@ -2336,11 +2309,6 @@ cliui@^8.0.1: strip-ansi "^6.0.1" wrap-ansi "^7.0.0" -cluster-key-slot@1.1.2: - version "1.1.2" - resolved "https://registry.yarnpkg.com/cluster-key-slot/-/cluster-key-slot-1.1.2.tgz#88ddaa46906e303b5de30d3153b7d9fe0a0c19ac" - integrity sha512-RMr0FhtfXemyinomL4hrWcYJxmX6deFdCxpJzhDttxgO1+bcCnkk+9drydLVDmAMG7NE6aN/fl4F7ucU/90gAA== - co@^4.6.0: version "4.6.0" resolved "https://registry.yarnpkg.com/co/-/co-4.6.0.tgz#6ea6bdf3d853ae54ccb8e47bfa0bf3f9031fb184" @@ -4988,17 +4956,6 @@ read-pkg@^5.2.0: parse-json "^5.0.0" type-fest "^0.6.0" -redis@^5.10.0: - version "5.10.0" - resolved "https://registry.yarnpkg.com/redis/-/redis-5.10.0.tgz#c1b26ba2acd9c5fcc0d1724a3c7f0984ca43f48b" - integrity sha512-0/Y+7IEiTgVGPrLFKy8oAEArSyEJkU0zvgV5xyi9NzNQ+SLZmyFbUsWIbgPcd4UdUh00opXGKlXJwMmsis5Byw== - dependencies: - "@redis/bloom" "5.10.0" - "@redis/client" "5.10.0" - "@redis/json" "5.10.0" - "@redis/search" "5.10.0" - "@redis/time-series" "5.10.0" - reflect.getprototypeof@^1.0.6, reflect.getprototypeof@^1.0.9: version "1.0.10" resolved "https://registry.yarnpkg.com/reflect.getprototypeof/-/reflect.getprototypeof-1.0.10.tgz#c629219e78a3316d8b604c765ef68996964e7bf9"