cached fetcher debug env var

This commit is contained in:
k00b 2024-10-10 09:35:39 -05:00
parent 7eaaa7ce44
commit c634c61dd2
2 changed files with 6 additions and 2 deletions

View File

@ -21,4 +21,5 @@ PRISMA_SLOW_LOGS_MS=50
GRAPHQL_SLOW_LOGS_MS=50
DB_APP_CONNECTION_LIMIT=4
DB_WORKER_CONNECTION_LIMIT=2
DB_TRANSACTION_TIMEOUT=10000
DB_TRANSACTION_TIMEOUT=10000
DEBUG_CACHED_FETCHER=1

View File

@ -98,7 +98,10 @@ function createDebugLogger (name, cache, debug) {
}
}
export function cachedFetcher (fetcher, { maxSize = 100, cacheExpiry, forceRefreshThreshold, keyGenerator, debug = false }) {
export function cachedFetcher (fetcher, {
maxSize = 100, cacheExpiry, forceRefreshThreshold,
keyGenerator, debug = process.env.DEBUG_CACHED_FETCHER
}) {
const cache = new LRUCache(maxSize)
const name = fetcher.name || fetcher.toString().slice(0, 20).replace(/\s+/g, '_')
const logger = createDebugLogger(name, cache, debug)