pg-cache 1.0.1 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/index.js +1 -1
- package/esm/lru.js +2 -2
- package/esm/pg.js +1 -1
- package/index.d.ts +1 -1
- package/index.js +1 -1
- package/lru.js +2 -2
- package/package.json +5 -5
- package/pg.js +1 -1
package/esm/index.js
CHANGED
package/esm/lru.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { LRUCache } from 'lru-cache';
|
|
2
1
|
import { Logger } from '@launchql/logger';
|
|
2
|
+
import { LRUCache } from 'lru-cache';
|
|
3
3
|
const log = new Logger('pg-cache');
|
|
4
4
|
const ONE_HOUR_IN_MS = 1000 * 60 * 60;
|
|
5
5
|
const ONE_DAY = ONE_HOUR_IN_MS * 24;
|
|
@@ -67,7 +67,7 @@ export class PgPoolCacheManager {
|
|
|
67
67
|
}
|
|
68
68
|
set(key, pool) {
|
|
69
69
|
if (this.closed)
|
|
70
|
-
throw new Error(
|
|
70
|
+
throw new Error(`Cannot add to cache after it has been closed (key: ${key})`);
|
|
71
71
|
this.pgCache.set(key, new ManagedPgPool(pool, key));
|
|
72
72
|
}
|
|
73
73
|
delete(key) {
|
package/esm/pg.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import pg from 'pg';
|
|
2
|
-
import { pgCache } from './lru';
|
|
3
2
|
import { getPgEnvOptions } from 'pg-env';
|
|
3
|
+
import { pgCache } from './lru';
|
|
4
4
|
const getDbString = (user, password, host, port, database) => `postgres://${user}:${password}@${host}:${port}/${database}`;
|
|
5
5
|
export const getPgPool = (pgConfig) => {
|
|
6
6
|
const config = getPgEnvOptions(pgConfig);
|
package/index.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -3,9 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getPgPool = exports.teardownPgPools = exports.PgPoolCacheManager = exports.pgCache = void 0;
|
|
4
4
|
// Main exports from pg-cache package
|
|
5
5
|
var lru_1 = require("./lru");
|
|
6
|
+
Object.defineProperty(exports, "close", { enumerable: true, get: function () { return lru_1.close; } });
|
|
6
7
|
Object.defineProperty(exports, "pgCache", { enumerable: true, get: function () { return lru_1.pgCache; } });
|
|
7
8
|
Object.defineProperty(exports, "PgPoolCacheManager", { enumerable: true, get: function () { return lru_1.PgPoolCacheManager; } });
|
|
8
|
-
Object.defineProperty(exports, "close", { enumerable: true, get: function () { return lru_1.close; } });
|
|
9
9
|
Object.defineProperty(exports, "teardownPgPools", { enumerable: true, get: function () { return lru_1.teardownPgPools; } });
|
|
10
10
|
var pg_1 = require("./pg");
|
|
11
11
|
Object.defineProperty(exports, "getPgPool", { enumerable: true, get: function () { return pg_1.getPgPool; } });
|
package/lru.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.teardownPgPools = exports.close = exports.pgCache = exports.PgPoolCacheManager = void 0;
|
|
4
|
-
const lru_cache_1 = require("lru-cache");
|
|
5
4
|
const logger_1 = require("@launchql/logger");
|
|
5
|
+
const lru_cache_1 = require("lru-cache");
|
|
6
6
|
const log = new logger_1.Logger('pg-cache');
|
|
7
7
|
const ONE_HOUR_IN_MS = 1000 * 60 * 60;
|
|
8
8
|
const ONE_DAY = ONE_HOUR_IN_MS * 24;
|
|
@@ -70,7 +70,7 @@ class PgPoolCacheManager {
|
|
|
70
70
|
}
|
|
71
71
|
set(key, pool) {
|
|
72
72
|
if (this.closed)
|
|
73
|
-
throw new Error(
|
|
73
|
+
throw new Error(`Cannot add to cache after it has been closed (key: ${key})`);
|
|
74
74
|
this.pgCache.set(key, new ManagedPgPool(pool, key));
|
|
75
75
|
}
|
|
76
76
|
delete(key) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pg-cache",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"author": "Dan Lynch <pyramation@gmail.com>",
|
|
5
5
|
"description": "PostgreSQL connection pool LRU cache manager",
|
|
6
6
|
"main": "index.js",
|
|
@@ -30,11 +30,11 @@
|
|
|
30
30
|
"test:watch": "jest --watch"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@launchql/logger": "^1.0
|
|
34
|
-
"@launchql/types": "^2.
|
|
33
|
+
"@launchql/logger": "^1.1.0",
|
|
34
|
+
"@launchql/types": "^2.3.0",
|
|
35
35
|
"lru-cache": "^11.1.0",
|
|
36
36
|
"pg": "^8.16.0",
|
|
37
|
-
"pg-env": "^1.0
|
|
37
|
+
"pg-env": "^1.1.0"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@types/pg": "^8.15.2"
|
|
@@ -48,5 +48,5 @@
|
|
|
48
48
|
"connection",
|
|
49
49
|
"launchql"
|
|
50
50
|
],
|
|
51
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "245029576886f5ac650aa5e8fa8cd8d5f47c258f"
|
|
52
52
|
}
|
package/pg.js
CHANGED
|
@@ -5,8 +5,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.getPgPool = void 0;
|
|
7
7
|
const pg_1 = __importDefault(require("pg"));
|
|
8
|
-
const lru_1 = require("./lru");
|
|
9
8
|
const pg_env_1 = require("pg-env");
|
|
9
|
+
const lru_1 = require("./lru");
|
|
10
10
|
const getDbString = (user, password, host, port, database) => `postgres://${user}:${password}@${host}:${port}/${database}`;
|
|
11
11
|
const getPgPool = (pgConfig) => {
|
|
12
12
|
const config = (0, pg_env_1.getPgEnvOptions)(pgConfig);
|