graphile-cache 1.4.9 → 1.4.11

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.
Files changed (2) hide show
  1. package/README.md +18 -17
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -8,22 +8,25 @@
8
8
  <a href="https://github.com/launchql/launchql/actions/workflows/run-tests.yaml">
9
9
  <img height="20" src="https://github.com/launchql/launchql/actions/workflows/run-tests.yaml/badge.svg" />
10
10
  </a>
11
- <a href="https://github.com/launchql/launchql/blob/main/LICENSE"><img height="20" src="https://img.shields.io/badge/license-MIT-blue.svg"/></a>
12
- <a href="https://www.npmjs.com/package/graphile-cache"><img height="20" src="https://img.shields.io/github/package-json/v/launchql/launchql?filename=graphile%2Fgraphile-cache%2Fpackage.json"/></a>
11
+ <a href="https://github.com/launchql/launchql/blob/main/LICENSE">
12
+ <img height="20" src="https://img.shields.io/badge/license-MIT-blue.svg"/>
13
+ </a>
14
+ <a href="https://www.npmjs.com/package/graphile-cache">
15
+ <img height="20" src="https://img.shields.io/github/package-json/v/launchql/launchql?filename=graphile%2Fgraphile-cache%2Fpackage.json"/>
16
+ </a>
13
17
  </p>
14
18
 
19
+ **`graphile-cache`** is an LRU cache for PostGraphile handlers with automatic cleanup when PostgreSQL pools are disposed.
15
20
 
16
- PostGraphile instance LRU cache with automatic cleanup when PostgreSQL pools are disposed.
21
+ > This package integrates with `pg-cache` for PostgreSQL pool management.
17
22
 
18
- ## Installation
23
+ ## 🚀 Installation
19
24
 
20
25
  ```bash
21
26
  npm install graphile-cache pg-cache
22
27
  ```
23
28
 
24
- Note: This package depends on `pg-cache` for the PostgreSQL pool management.
25
-
26
- ## Features
29
+ ## Features
27
30
 
28
31
  - LRU cache for PostGraphile instances
29
32
  - Automatic cleanup when associated PostgreSQL pools are disposed
@@ -31,26 +34,24 @@ Note: This package depends on `pg-cache` for the PostgreSQL pool management.
31
34
  - Service cache re-exported for convenience
32
35
  - TypeScript support
33
36
 
34
- ## How It Works
37
+ ## 🧠 How It Works
35
38
 
36
39
  When you import this package, it automatically registers a cleanup callback with `pg-cache`. When a PostgreSQL pool is disposed, any PostGraphile instances using that pool are automatically removed from the cache.
37
40
 
38
- ## Usage
41
+ ## 📦 Usage
39
42
 
40
- ### Basic Usage
43
+ ### Basic caching flow
41
44
 
42
45
  ```typescript
43
46
  import { graphileCache, GraphileCache } from 'graphile-cache';
44
47
  import { getPgPool } from 'pg-cache';
45
48
  import { postgraphile } from 'postgraphile';
46
49
 
47
- // Create a PostGraphile instance
48
50
  const pgPool = getPgPool({ database: 'mydb' });
49
51
  const handler = postgraphile(pgPool, 'public', {
50
52
  // PostGraphile options
51
53
  });
52
54
 
53
- // Cache it
54
55
  const cacheEntry: GraphileCache = {
55
56
  pgPool,
56
57
  pgPoolKey: 'mydb',
@@ -66,7 +67,7 @@ if (cached) {
66
67
  }
67
68
  ```
68
69
 
69
- ### Automatic Cleanup
70
+ ### Automatic cleanup when pools disappear
70
71
 
71
72
  The cleanup happens automatically:
72
73
 
@@ -86,7 +87,7 @@ console.log(graphileCache.has('mydb.public')); // false
86
87
  console.log(graphileCache.has('mydb.private')); // false
87
88
  ```
88
89
 
89
- ### Complete Example
90
+ ### Complete example with Express
90
91
 
91
92
  ```typescript
92
93
  import { graphileCache, GraphileCache } from 'graphile-cache';
@@ -133,14 +134,14 @@ app.use((req, res, next) => {
133
134
  ```typescript
134
135
  import { closeAllCaches } from 'graphile-cache';
135
136
 
136
- // This closes all caches including pg pools
137
137
  process.on('SIGTERM', async () => {
138
+ // Closes all caches including pg pools
138
139
  await closeAllCaches();
139
140
  process.exit(0);
140
141
  });
141
142
  ```
142
143
 
143
- ## API Reference
144
+ ## 📘 API Reference
144
145
 
145
146
  ### graphileCache
146
147
 
@@ -170,7 +171,7 @@ Closes all caches including the service cache, graphile cache, and all PostgreSQ
170
171
 
171
172
  Re-exported from `pg-cache` for convenience.
172
173
 
173
- ## Integration Details
174
+ ## 🔌 Integration Details
174
175
 
175
176
  The integration with `pg-cache` happens automatically when this module is imported. The cleanup callback is registered immediately, ensuring that PostGraphile instances are cleaned up whenever their associated PostgreSQL pools are disposed.
176
177
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "graphile-cache",
3
- "version": "1.4.9",
3
+ "version": "1.4.11",
4
4
  "author": "Dan Lynch <pyramation@gmail.com>",
5
5
  "description": "PostGraphile LRU cache with automatic pool cleanup integration",
6
6
  "main": "index.js",
@@ -49,5 +49,5 @@
49
49
  "postgresql",
50
50
  "launchql"
51
51
  ],
52
- "gitHead": "3812f24a480b2035b3413ec7fecfe492f294e590"
52
+ "gitHead": "00c90828cab8d3e306ebb2bc6053aab4aa9ae807"
53
53
  }