graphile-cache 1.4.10 → 1.4.12

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 +17 -19
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -16,17 +16,17 @@
16
16
  </a>
17
17
  </p>
18
18
 
19
- PostGraphile instance LRU cache with automatic cleanup when PostgreSQL pools are disposed.
19
+ **`graphile-cache`** is an LRU cache for PostGraphile handlers with automatic cleanup when PostgreSQL pools are disposed.
20
20
 
21
- ## Installation
21
+ > This package integrates with `pg-cache` for PostgreSQL pool management.
22
+
23
+ ## 🚀 Installation
22
24
 
23
25
  ```bash
24
26
  npm install graphile-cache pg-cache
25
27
  ```
26
28
 
27
- Note: This package depends on `pg-cache` for the PostgreSQL pool management.
28
-
29
- ## Features
29
+ ## Features
30
30
 
31
31
  - LRU cache for PostGraphile instances
32
32
  - Automatic cleanup when associated PostgreSQL pools are disposed
@@ -34,26 +34,24 @@ Note: This package depends on `pg-cache` for the PostgreSQL pool management.
34
34
  - Service cache re-exported for convenience
35
35
  - TypeScript support
36
36
 
37
- ## How It Works
37
+ ## 🧠 How It Works
38
38
 
39
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.
40
40
 
41
- ## Usage
41
+ ## 📦 Usage
42
42
 
43
- ### Basic Usage
43
+ ### Basic caching flow
44
44
 
45
45
  ```typescript
46
46
  import { graphileCache, GraphileCache } from 'graphile-cache';
47
47
  import { getPgPool } from 'pg-cache';
48
48
  import { postgraphile } from 'postgraphile';
49
49
 
50
- // Create a PostGraphile instance
51
50
  const pgPool = getPgPool({ database: 'mydb' });
52
51
  const handler = postgraphile(pgPool, 'public', {
53
52
  // PostGraphile options
54
53
  });
55
54
 
56
- // Cache it
57
55
  const cacheEntry: GraphileCache = {
58
56
  pgPool,
59
57
  pgPoolKey: 'mydb',
@@ -69,7 +67,7 @@ if (cached) {
69
67
  }
70
68
  ```
71
69
 
72
- ### Automatic Cleanup
70
+ ### Automatic cleanup
73
71
 
74
72
  The cleanup happens automatically:
75
73
 
@@ -89,7 +87,7 @@ console.log(graphileCache.has('mydb.public')); // false
89
87
  console.log(graphileCache.has('mydb.private')); // false
90
88
  ```
91
89
 
92
- ### Complete Example
90
+ ### Complete example with Express
93
91
 
94
92
  ```typescript
95
93
  import { graphileCache, GraphileCache } from 'graphile-cache';
@@ -98,13 +96,13 @@ import { postgraphile } from 'postgraphile';
98
96
 
99
97
  function getGraphileInstance(database: string, schema: string): GraphileCache {
100
98
  const key = `${database}.${schema}`;
101
-
99
+
102
100
  // Check cache first
103
101
  const cached = graphileCache.get(key);
104
102
  if (cached) {
105
103
  return cached;
106
104
  }
107
-
105
+
108
106
  // Create new instance
109
107
  const pgPool = getPgPool({ database });
110
108
  const handler = postgraphile(pgPool, schema, {
@@ -112,13 +110,13 @@ function getGraphileInstance(database: string, schema: string): GraphileCache {
112
110
  graphiqlRoute: '/graphiql',
113
111
  // other options...
114
112
  });
115
-
113
+
116
114
  const entry: GraphileCache = {
117
115
  pgPool,
118
116
  pgPoolKey: database,
119
117
  handler
120
118
  };
121
-
119
+
122
120
  // Cache it
123
121
  graphileCache.set(key, entry);
124
122
  return entry;
@@ -136,14 +134,14 @@ app.use((req, res, next) => {
136
134
  ```typescript
137
135
  import { closeAllCaches } from 'graphile-cache';
138
136
 
139
- // This closes all caches including pg pools
140
137
  process.on('SIGTERM', async () => {
138
+ // Closes all caches including pg pools
141
139
  await closeAllCaches();
142
140
  process.exit(0);
143
141
  });
144
142
  ```
145
143
 
146
- ## API Reference
144
+ ## 📘 API Reference
147
145
 
148
146
  ### graphileCache
149
147
 
@@ -173,7 +171,7 @@ Closes all caches including the service cache, graphile cache, and all PostgreSQ
173
171
 
174
172
  Re-exported from `pg-cache` for convenience.
175
173
 
176
- ## Integration Details
174
+ ## 🔌 Integration Details
177
175
 
178
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.
179
177
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "graphile-cache",
3
- "version": "1.4.10",
3
+ "version": "1.4.12",
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": "4e1ff9771c2b07808a9830281abc24d12c689187"
52
+ "gitHead": "ea3f6b8d86ba521ee629411efb4cf4133cc6e302"
53
53
  }