fix: remove invalid cache lru

This commit is contained in:
Yanlong Wang 2025-04-10 21:47:41 +08:00
parent 0cf4a9ede1
commit b6ac1782dc
No known key found for this signature in database
GPG Key ID: C0A623C0BADF9F37

View File

@ -18,17 +18,8 @@ import envConfig from '../shared/services/secrets';
import { JinaEmbeddingsDashboardHTTP } from '../shared/3rd-party/jina-embeddings';
import { JinaEmbeddingsTokenAccount } from '../shared/db/jina-embeddings-token-account';
import { LRUCache } from 'lru-cache';
const authDtoLogger = logger.child({ service: 'JinaAuthDTO' });
const invalidTokenLRU = new LRUCache({
max: 256,
ttl: 60 * 60 * 1000,
updateAgeOnGet: false,
updateAgeOnHas: false,
});
const THE_VERY_SAME_JINA_EMBEDDINGS_CLIENT = new JinaEmbeddingsDashboardHTTP(envConfig.JINA_EMBEDDINGS_DASHBOARD_API_KEY);
@ -91,12 +82,6 @@ export class JinaEmbeddingsAuthDTO extends AutoCastable {
});
}
if (invalidTokenLRU.get(this.bearerToken)) {
throw new AuthenticationFailedError({
message: 'Invalid API key, please get a new one from https://jina.ai'
});
}
let firestoreDegradation = false;
let account;
try {
@ -165,7 +150,6 @@ export class JinaEmbeddingsAuthDTO extends AutoCastable {
authDtoLogger.warn(`Failed to get user brief: ${err}`, { err: marshalErrorLike(err) });
if (err?.status === 401) {
invalidTokenLRU.set(this.bearerToken, true);
throw new AuthenticationFailedError({
message: 'Invalid API key, please get a new one from https://jina.ai'
});