feat(cache): Remove deprecated cache configuration

Remove metadata/scrobble/auth config that was deprecated in 0.14.0
This commit is contained in:
FoxxMD
2026-07-28 01:56:26 +00:00
parent 2887600aa0
commit d96073282c
3 changed files with 9 additions and 49 deletions
+5 -29
View File
@@ -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
}
};
}
+3 -19
View File
@@ -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<typeof cacheConfigUserSchema>;
@@ -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(),