Skip to content

Commit

Permalink
fix(sql): fix POSTGRAPHILE_PREPARED_STATEMENT_CACHE_SIZE envvar (#639)
Browse files Browse the repository at this point in the history
  • Loading branch information
benjie committed Aug 11, 2020
1 parent 4944e63 commit 5e79bd0
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/graphile-build-pg/src/pgPrepareAndRun.js
Expand Up @@ -3,8 +3,12 @@ import { createHash } from "crypto";
import LRU from "@graphile/lru";
import type { PoolClient } from "pg";

const cacheSizeFromEnv = parseInt(
process.env.POSTGRAPHILE_PREPARED_STATEMENT_CACHE_SIZE,
10
);
const POSTGRAPHILE_PREPARED_STATEMENT_CACHE_SIZE =
parseInt(process.env.POSTGRAPHILE_PREPARED_STATEMENT_CACHE_SIZE, 10) || 100;
!!cacheSizeFromEnv || cacheSizeFromEnv === 0 ? cacheSizeFromEnv : 100;

let lastString: string;
let lastHash: string;
Expand All @@ -27,7 +31,7 @@ export default function pgPrepareAndRun(
const connection = pgClient.connection;
if (
!values ||
POSTGRAPHILE_PREPARED_STATEMENT_CACHE_SIZE < 1 ||
POSTGRAPHILE_PREPARED_STATEMENT_CACHE_SIZE < 2 ||
!connection ||
!connection.parsedStatements
) {
Expand Down

0 comments on commit 5e79bd0

Please sign in to comment.