From d96073282cbae9cd4498610be5106a96ab962c7e Mon Sep 17 00:00:00 2001 From: FoxxMD Date: Tue, 28 Jul 2026 01:41:41 +0000 Subject: [PATCH] feat(cache): Remove deprecated cache configuration Remove metadata/scrobble/auth config that was deprecated in 0.14.0 --- src/backend/common/Cache.ts | 34 +++---------------- src/backend/common/infrastructure/Atomic.ts | 22 ++---------- .../common/infrastructure/config/aioConfig.ts | 2 +- 3 files changed, 9 insertions(+), 49 deletions(-) diff --git a/src/backend/common/Cache.ts b/src/backend/common/Cache.ts index f696573a..b15acb5c 100644 --- a/src/backend/common/Cache.ts +++ b/src/backend/common/Cache.ts @@ -14,7 +14,7 @@ import { getConfigDir } from './index.ts'; import path from 'path'; import { cacheFunctions } from "@foxxmd/regex-buddy-core"; import { fileOrDirectoryIsWriteable } from '../utils/FSUtils.ts'; -import { asCacheConfig, type CacheAuthProvider, type CacheConfig, type CacheConfigOptions, type CacheConfigUser, type CacheScrobbleProvider } from './infrastructure/Atomic.ts'; +import { asCacheConfig, type CacheAuthProvider, type CacheConfig, type CacheConfigOptions, type CacheConfigUser } from './infrastructure/Atomic.ts'; import { Typeson } from 'typeson'; import { builtin } from 'typeson-registry'; import { loggerNoop } from './MaybeLogger.ts'; @@ -89,7 +89,6 @@ export class MSCache { connection: aConn, //...restAuth } = {}, - regex = 200, } = config; this.config = { @@ -104,11 +103,10 @@ export class MSCache { auth: { provider: aProvider, connection: aConn, - }, - regex + } }; - this.regexCache = cacheFunctions(this.config.regex); + this.regexCache = cacheFunctions(200); // for testing we default to in memory const inMemory = new Cacheable({primary: initMemoryCache({lruSize: 500, ttl: '1m'})}); @@ -536,27 +534,11 @@ export const parseUserConfig = (config: CacheConfigUser = {}, parentLogger: Logg // connection: mConn = process.env.CACHE_METADATA_CONN, // //...restMetadata // } = {}, - scrobble: { - provider: sProvider = (process.env.CACHE_SCROBBLE as (CacheScrobbleProvider | undefined) ?? 'file'), - connection = (process.env.CACHE_SCROBBLE_CONN ?? getConfigDir()), - ...restScrobble - } = {}, auth: { provider: aProvider = (process.env.CACHE_AUTH as (CacheAuthProvider | undefined) ?? 'file'), //...restAuth - } = {}, - regex = 200, + } = {} } = config; - - if(config.metadata !== undefined) { - logger.warn('Configuring cache.metadata is no longer supported. Refer to the Caching docs.'); - } - if(config.scrobble !== undefined) { - logger.warn('Configuring cache.scrobble is no longer supported. Refer to the Caching docs.'); - } - if(config.auth?.connection !== undefined) { - logger.warn('Configuring cache.auth.connection is no longer supported. Refer to the Caching docs.'); - } let authConn: string, authProvider = aProvider; @@ -581,15 +563,9 @@ export const parseUserConfig = (config: CacheConfigUser = {}, parentLogger: Logg provider: valkey !== undefined ? 'valkey' : false, connection: valkey, }, - scrobble: { - provider: sProvider, - connection, - ...restScrobble - }, auth: { provider: authProvider, connection: authConn, - }, - regex + } }; } \ No newline at end of file diff --git a/src/backend/common/infrastructure/Atomic.ts b/src/backend/common/infrastructure/Atomic.ts index 3b4abc41..ad1ef000 100644 --- a/src/backend/common/infrastructure/Atomic.ts +++ b/src/backend/common/infrastructure/Atomic.ts @@ -12,7 +12,6 @@ import type { ClientType } from "../../../core/Atomic.ts"; import assert from 'assert'; import * as path from 'path'; import * as z from 'zod'; -import { stripIndents } from 'common-tags'; export const __filename = import.meta.filename; export const projectRootDir = path.resolve(__filename, '../../../../../'); @@ -272,31 +271,16 @@ export interface CacheConfigOptions { metadata?: CacheMetadataConfig; scrobble?: CacheScrobbleConfig; auth?: CacheAuthConfig; - /** Number of regex functions to cache (LRU) - * - * @default 200 - */ - regex?: number } export const cacheConfigUserAuthSchema = z.object({ provider: z.union([z.literal('valkey'), z.literal('file')]), -}).catchall(z.any()); +}).meta({description: 'The cache type to use for Auth'}); -// The top-level (and `auth`) catchalls allow deprecated `scrobble`/`metadata` config keys to still be read off -// this type at runtime (see Cache.ts#parseUserConfig) without having them show up in schema docs. export const cacheConfigUserSchema = z.object({ auth: cacheConfigUserAuthSchema.optional(), - valkey: z.string().optional(), - /** Number of regex functions to cache (LRU) - * - * @default 200 - */ - regex: z.number().optional().meta({ - description: "Number of regex functions to cache (LRU)", - default: 200 - }), -}).catchall(z.any()); + valkey: z.string().optional() +}).meta({title: 'Cache Config', description: 'Configuration for Caching'}); export type CacheConfigUser = z.infer; diff --git a/src/backend/common/infrastructure/config/aioConfig.ts b/src/backend/common/infrastructure/config/aioConfig.ts index faade95b..e013b8d1 100644 --- a/src/backend/common/infrastructure/config/aioConfig.ts +++ b/src/backend/common/infrastructure/config/aioConfig.ts @@ -111,7 +111,7 @@ export const aioConfigSchema = z.object({ examples: [false] }), - cache: cacheConfigUserSchema.optional(), + cache: cacheConfigUserSchema.optional().meta({description: 'Configuration for Caching'}), transformers: z.array(transformerCommonConfigSchema).optional(), -- 2.51.2