Skip to content

Commit 0da1678

Browse files
committed
chore: move cache size to env var
1 parent 598f7a7 commit 0da1678

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

src/server/constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,6 @@ export const GENERATE_TYPES =
2525
export const GENERATE_TYPES_INCLUDED_SCHEMAS =
2626
GENERATE_TYPES && process.argv[5] === '--include-schemas' ? process.argv[6]?.split(',') ?? [] : []
2727

28+
export const CONNECTIONS_CACHE_SIZE = Number(process.env.PG_META_CONNECTIONS_CACHE_SIZE || '100')
2829
export const DEFAULT_POOL_CONFIG = { max: 1, connectionTimeoutMillis: PG_CONN_TIMEOUT_SECS * 1000 }
2930
export const PG_META_REQ_HEADER = process.env.PG_META_REQ_HEADER || 'request-id'

src/server/pgMetaCache.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import LruCache from 'lru-cache'
22
import PostgresMeta from '../lib/PostgresMeta.js'
3-
import { DEFAULT_POOL_CONFIG } from './constants.js'
3+
import { CONNECTIONS_CACHE_SIZE, DEFAULT_POOL_CONFIG } from './constants.js'
44

55
const cache = new LruCache<string, PostgresMeta>({
6-
max: 100,
6+
max: CONNECTIONS_CACHE_SIZE,
77
dispose: async (value) => {
88
await value.end()
99
},

0 commit comments

Comments
 (0)