/*
 *  This file is part of CoCalc: Copyright © 2021 Sagemath, Inc.
 *  License: AGPLv3 s.t. "Commons Clause" – see LICENSE.md for details
 */

import {
  pghost as host,
  pguser as user,
  pgdatabase as database,
} from "@cocalc/backend/data";
import dbPassword from "./password";
export * from "./util";
import /*getCachedPool, */{ Length } from "./cached";

import { Pool } from "pg";
let pool: Pool | undefined = undefined;

export default function getPool(cacheLength?: Length): Pool {
  // temporarily disabling all caching, since there is an issue.
  //   if (cacheLength != null) {
  //     return getCachedPool(cacheLength);
  //   }
  cacheLength = cacheLength;
  if (pool == null) {
    pool = new Pool({ password: dbPassword(), user, host, database });
  }
  return pool;
}

/*
 *  This file is part of CoCalc: Copyright © 2021 Sagemath, Inc.
 *  License: AGPLv3 s.t. "Commons Clause" – see LICENSE.md for details
 */

import {
  pghost as host,
  pguser as user,
  pgdatabase as database,
} from "@cocalc/backend/data";
import dbPassword from "./password";
export * from "./util";
import getCachedPool, { Length } from "./cached";

import { Pool } from "pg";
let pool: Pool | undefined = undefined;

export default function getPool(cacheLength?: Length): Pool {
  if (cacheLength != null) {
    return getCachedPool(cacheLength);
  }
  if (pool == null) {
    pool = new Pool({ password: dbPassword(), user, host, database });
  }
  return pool;
}

Revert "temporarily disable certain database caching used by next app"
Revert "temporarily disable certain database caching used by next app"

This reverts commit dfe98248abcc04413e3d2ab1e2c662f35c6a4bba.
