@pantheon-systems/nextjs-cache-handler 0.1.0
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/README.md +256 -0
- package/dist/edge/edge-cache-clear.d.ts +64 -0
- package/dist/edge/edge-cache-clear.d.ts.map +1 -0
- package/dist/edge/edge-cache-clear.js +245 -0
- package/dist/edge/edge-cache-clear.js.map +1 -0
- package/dist/handlers/base.d.ts +69 -0
- package/dist/handlers/base.d.ts.map +1 -0
- package/dist/handlers/base.js +278 -0
- package/dist/handlers/base.js.map +1 -0
- package/dist/handlers/file.d.ts +62 -0
- package/dist/handlers/file.d.ts.map +1 -0
- package/dist/handlers/file.js +332 -0
- package/dist/handlers/file.js.map +1 -0
- package/dist/handlers/gcs.d.ts +66 -0
- package/dist/handlers/gcs.d.ts.map +1 -0
- package/dist/handlers/gcs.js +407 -0
- package/dist/handlers/gcs.js.map +1 -0
- package/dist/handlers/index.d.ts +4 -0
- package/dist/handlers/index.d.ts.map +1 -0
- package/dist/handlers/index.js +4 -0
- package/dist/handlers/index.js.map +1 -0
- package/dist/index.d.ts +47 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +73 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +119 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/build-detection.d.ts +10 -0
- package/dist/utils/build-detection.d.ts.map +1 -0
- package/dist/utils/build-detection.js +57 -0
- package/dist/utils/build-detection.js.map +1 -0
- package/dist/utils/index.d.ts +5 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +5 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/logger.d.ts +34 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +54 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/serialization.d.ts +12 -0
- package/dist/utils/serialization.d.ts.map +1 -0
- package/dist/utils/serialization.js +137 -0
- package/dist/utils/serialization.js.map +1 -0
- package/dist/utils/static-routes.d.ts +7 -0
- package/dist/utils/static-routes.d.ts.map +1 -0
- package/dist/utils/static-routes.js +52 -0
- package/dist/utils/static-routes.js.map +1 -0
- package/dist/utils/tags-buffer.d.ts +63 -0
- package/dist/utils/tags-buffer.d.ts.map +1 -0
- package/dist/utils/tags-buffer.js +181 -0
- package/dist/utils/tags-buffer.js.map +1 -0
- package/package.json +58 -0
|
@@ -0,0 +1,332 @@
|
|
|
1
|
+
import * as fs from 'fs';
|
|
2
|
+
import * as path from 'path';
|
|
3
|
+
import { promisify } from 'util';
|
|
4
|
+
import { BaseCacheHandler } from './base.js';
|
|
5
|
+
import { getStaticRoutes } from '../utils/static-routes.js';
|
|
6
|
+
import { TagsBuffer } from '../utils/tags-buffer.js';
|
|
7
|
+
import { createLogger } from '../utils/logger.js';
|
|
8
|
+
const fileLog = createLogger('FileCacheHandler');
|
|
9
|
+
const writeFile = promisify(fs.writeFile);
|
|
10
|
+
const readFile = promisify(fs.readFile);
|
|
11
|
+
const mkdir = promisify(fs.mkdir);
|
|
12
|
+
/**
|
|
13
|
+
* File-based cache handler for local development.
|
|
14
|
+
* Stores cache entries in the .next/cache directory.
|
|
15
|
+
*/
|
|
16
|
+
export class FileCacheHandler extends BaseCacheHandler {
|
|
17
|
+
constructor(context) {
|
|
18
|
+
super(context, 'FileCacheHandler');
|
|
19
|
+
this.baseDir = path.join(process.cwd(), '.next', 'cache');
|
|
20
|
+
this.fetchCacheDir = path.join(this.baseDir, 'fetch-cache');
|
|
21
|
+
this.routeCacheDir = path.join(this.baseDir, 'route-cache');
|
|
22
|
+
// Store build-meta.json outside .next/ to survive Next.js cache clearing during builds
|
|
23
|
+
this.buildMetaFile = path.join(process.cwd(), '.cache', 'build-meta.json');
|
|
24
|
+
this.tagsDir = path.join(this.baseDir, 'tags');
|
|
25
|
+
this.tagsMapFile = path.join(this.tagsDir, 'tags.json');
|
|
26
|
+
// Create tags buffer for batched writes (improves performance)
|
|
27
|
+
this.tagsBuffer = new TagsBuffer({
|
|
28
|
+
flushIntervalMs: 100, // File system can handle faster flushes than GCS
|
|
29
|
+
readTagsMapping: () => Promise.resolve(this.readTagsMappingDirect()),
|
|
30
|
+
writeTagsMapping: (mapping) => {
|
|
31
|
+
this.writeTagsMappingDirect(mapping);
|
|
32
|
+
return Promise.resolve();
|
|
33
|
+
},
|
|
34
|
+
handlerName: 'FileCacheHandler',
|
|
35
|
+
});
|
|
36
|
+
this.ensureCacheDir();
|
|
37
|
+
// Initialize asynchronously (don't await to avoid blocking constructor)
|
|
38
|
+
this.initialize().catch(() => { });
|
|
39
|
+
}
|
|
40
|
+
ensureCacheDir() {
|
|
41
|
+
try {
|
|
42
|
+
fs.mkdirSync(this.fetchCacheDir, { recursive: true });
|
|
43
|
+
fs.mkdirSync(this.routeCacheDir, { recursive: true });
|
|
44
|
+
fs.mkdirSync(this.tagsDir, { recursive: true });
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
if (error.code !== 'EEXIST') {
|
|
48
|
+
this.log.error('Error creating cache directories:', error);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
// ============================================================================
|
|
53
|
+
// Tags mapping implementation (buffered for improved performance)
|
|
54
|
+
// ============================================================================
|
|
55
|
+
async initializeTagsMapping() {
|
|
56
|
+
try {
|
|
57
|
+
if (!fs.existsSync(this.tagsMapFile)) {
|
|
58
|
+
fs.writeFileSync(this.tagsMapFile, JSON.stringify({}, null, 2), 'utf-8');
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
catch {
|
|
62
|
+
// Silently fail - tags mapping will be created on first write
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Read tags mapping, flushing any pending updates first to ensure accuracy.
|
|
67
|
+
*/
|
|
68
|
+
async readTagsMapping() {
|
|
69
|
+
// Flush pending updates before reading to ensure we have accurate data
|
|
70
|
+
await this.tagsBuffer.flush();
|
|
71
|
+
return this.readTagsMappingDirect();
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Direct read from file system without flushing buffer.
|
|
75
|
+
* Used internally by the buffer.
|
|
76
|
+
*/
|
|
77
|
+
readTagsMappingDirect() {
|
|
78
|
+
try {
|
|
79
|
+
if (!fs.existsSync(this.tagsMapFile)) {
|
|
80
|
+
return {};
|
|
81
|
+
}
|
|
82
|
+
const data = fs.readFileSync(this.tagsMapFile, 'utf-8');
|
|
83
|
+
return JSON.parse(data);
|
|
84
|
+
}
|
|
85
|
+
catch (error) {
|
|
86
|
+
this.log.warn('Error reading tags mapping:', error);
|
|
87
|
+
return {};
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Write tags mapping directly to file system.
|
|
92
|
+
* Used by the buffer for batched writes.
|
|
93
|
+
*/
|
|
94
|
+
async writeTagsMapping(tagsMapping) {
|
|
95
|
+
this.writeTagsMappingDirect(tagsMapping);
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Direct write to file system (sync).
|
|
99
|
+
* Used internally by the buffer.
|
|
100
|
+
*/
|
|
101
|
+
writeTagsMappingDirect(tagsMapping) {
|
|
102
|
+
try {
|
|
103
|
+
fs.writeFileSync(this.tagsMapFile, JSON.stringify(tagsMapping, null, 2), 'utf-8');
|
|
104
|
+
}
|
|
105
|
+
catch (error) {
|
|
106
|
+
this.log.error('Error writing tags mapping:', error);
|
|
107
|
+
throw error; // Re-throw so buffer can retry
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Override to use buffered updates instead of immediate writes.
|
|
112
|
+
*/
|
|
113
|
+
async updateTagsMapping(cacheKey, tags, isDelete = false) {
|
|
114
|
+
if (isDelete) {
|
|
115
|
+
this.tagsBuffer.deleteKey(cacheKey);
|
|
116
|
+
}
|
|
117
|
+
else if (tags.length > 0) {
|
|
118
|
+
this.tagsBuffer.addTags(cacheKey, tags);
|
|
119
|
+
}
|
|
120
|
+
// Updates are queued and will be flushed automatically
|
|
121
|
+
this.log.debug(`Queued tags update for ${cacheKey} (pending: ${this.tagsBuffer.pendingCount})`);
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Override to use buffered deletes instead of immediate writes.
|
|
125
|
+
*/
|
|
126
|
+
async updateTagsMappingBulkDelete(cacheKeysToDelete, _tagsMapping) {
|
|
127
|
+
this.tagsBuffer.deleteKeys(cacheKeysToDelete);
|
|
128
|
+
// Force flush after bulk delete to ensure consistency for revalidation
|
|
129
|
+
await this.tagsBuffer.flush();
|
|
130
|
+
}
|
|
131
|
+
// ============================================================================
|
|
132
|
+
// Cache entry implementation
|
|
133
|
+
// ============================================================================
|
|
134
|
+
getCacheFilePath(cacheKey, cacheType) {
|
|
135
|
+
const safeKey = cacheKey.replace(/[^a-zA-Z0-9-]/g, '_');
|
|
136
|
+
const dir = cacheType === 'fetch' ? this.fetchCacheDir : this.routeCacheDir;
|
|
137
|
+
return path.join(dir, `${safeKey}.json`);
|
|
138
|
+
}
|
|
139
|
+
async readCacheEntry(cacheKey, cacheType) {
|
|
140
|
+
try {
|
|
141
|
+
const filePath = this.getCacheFilePath(cacheKey, cacheType);
|
|
142
|
+
const data = await readFile(filePath, 'utf-8');
|
|
143
|
+
const parsedData = JSON.parse(data);
|
|
144
|
+
return this.deserializeFromStorage({ [cacheKey]: parsedData })[cacheKey] || null;
|
|
145
|
+
}
|
|
146
|
+
catch {
|
|
147
|
+
return null;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
async writeCacheEntry(cacheKey, cacheValue, cacheType) {
|
|
151
|
+
try {
|
|
152
|
+
this.ensureCacheDir();
|
|
153
|
+
const filePath = this.getCacheFilePath(cacheKey, cacheType);
|
|
154
|
+
const serializedData = this.serializeForStorage({ [cacheKey]: cacheValue });
|
|
155
|
+
await writeFile(filePath, JSON.stringify(serializedData[cacheKey], null, 2), 'utf-8');
|
|
156
|
+
}
|
|
157
|
+
catch (error) {
|
|
158
|
+
this.log.error(`Error writing cache entry ${cacheKey}:`, error);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
async deleteCacheEntry(cacheKey, cacheType) {
|
|
162
|
+
try {
|
|
163
|
+
const filePath = this.getCacheFilePath(cacheKey, cacheType);
|
|
164
|
+
await fs.promises.unlink(filePath);
|
|
165
|
+
}
|
|
166
|
+
catch (error) {
|
|
167
|
+
if (error.code !== 'ENOENT') {
|
|
168
|
+
this.log.error(`Error deleting cache entry ${cacheKey}:`, error);
|
|
169
|
+
}
|
|
170
|
+
throw error;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
// ============================================================================
|
|
174
|
+
// Build meta implementation
|
|
175
|
+
// ============================================================================
|
|
176
|
+
async readBuildMeta() {
|
|
177
|
+
const data = await readFile(this.buildMetaFile, 'utf-8');
|
|
178
|
+
return JSON.parse(data);
|
|
179
|
+
}
|
|
180
|
+
async writeBuildMeta(meta) {
|
|
181
|
+
const buildMetaDir = path.dirname(this.buildMetaFile);
|
|
182
|
+
await mkdir(buildMetaDir, { recursive: true });
|
|
183
|
+
await writeFile(this.buildMetaFile, JSON.stringify(meta), 'utf-8');
|
|
184
|
+
}
|
|
185
|
+
async invalidateRouteCache() {
|
|
186
|
+
try {
|
|
187
|
+
await fs.promises.rm(this.routeCacheDir, { recursive: true, force: true });
|
|
188
|
+
await fs.promises.mkdir(this.routeCacheDir, { recursive: true });
|
|
189
|
+
}
|
|
190
|
+
catch {
|
|
191
|
+
// Directory might not exist or can't be created - not critical
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
// ============================================================================
|
|
196
|
+
// Standalone functions for API usage
|
|
197
|
+
// ============================================================================
|
|
198
|
+
/**
|
|
199
|
+
* Get cache statistics for the file-based cache.
|
|
200
|
+
*/
|
|
201
|
+
export async function getSharedCacheStats() {
|
|
202
|
+
const fetchCacheDir = path.join(process.cwd(), '.next', 'cache', 'fetch-cache');
|
|
203
|
+
const routeCacheDir = path.join(process.cwd(), '.next', 'cache', 'route-cache');
|
|
204
|
+
const keys = [];
|
|
205
|
+
const entries = [];
|
|
206
|
+
try {
|
|
207
|
+
await processCacheDirectory(fetchCacheDir, 'fetch', keys, entries);
|
|
208
|
+
await processCacheDirectory(routeCacheDir, 'route', keys, entries);
|
|
209
|
+
fileLog.debug(`Found ${keys.length} cache entries ` +
|
|
210
|
+
`(${keys.filter((k) => k.startsWith('fetch:')).length} fetch, ` +
|
|
211
|
+
`${keys.filter((k) => k.startsWith('route:')).length} route)`);
|
|
212
|
+
return { size: keys.length, keys, entries };
|
|
213
|
+
}
|
|
214
|
+
catch (error) {
|
|
215
|
+
fileLog.error('Error reading cache directories:', error);
|
|
216
|
+
return { size: 0, keys: [], entries: [] };
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
async function processCacheDirectory(dir, cacheType, keys, entries) {
|
|
220
|
+
try {
|
|
221
|
+
const files = await fs.promises.readdir(dir);
|
|
222
|
+
const jsonFiles = files.filter((file) => file.endsWith('.json'));
|
|
223
|
+
for (const file of jsonFiles) {
|
|
224
|
+
await processJsonCacheFile(dir, file, cacheType, keys, entries);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
catch {
|
|
228
|
+
// Directory might not exist
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
async function processJsonCacheFile(dir, file, cacheType, keys, entries) {
|
|
232
|
+
const cacheKey = file.replace('.json', '').replace(/_/g, '-');
|
|
233
|
+
const displayKey = `${cacheType}:${cacheKey}`;
|
|
234
|
+
keys.push(displayKey);
|
|
235
|
+
try {
|
|
236
|
+
const filePath = path.join(dir, file);
|
|
237
|
+
const data = await fs.promises.readFile(filePath, 'utf-8');
|
|
238
|
+
const cacheData = JSON.parse(data);
|
|
239
|
+
entries.push({
|
|
240
|
+
key: displayKey,
|
|
241
|
+
tags: cacheData.tags || [],
|
|
242
|
+
lastModified: cacheData.lastModified || Date.now(),
|
|
243
|
+
type: cacheType,
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
catch {
|
|
247
|
+
entries.push({
|
|
248
|
+
key: displayKey,
|
|
249
|
+
tags: [],
|
|
250
|
+
type: cacheType,
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* Clear all cache entries for the file-based cache.
|
|
256
|
+
*/
|
|
257
|
+
export async function clearSharedCache() {
|
|
258
|
+
const fetchCacheDir = path.join(process.cwd(), '.next', 'cache', 'fetch-cache');
|
|
259
|
+
const routeCacheDir = path.join(process.cwd(), '.next', 'cache', 'route-cache');
|
|
260
|
+
const tagsFilePath = path.join(process.cwd(), '.next', 'cache', 'tags', 'tags.json');
|
|
261
|
+
const staticRoutes = getStaticRoutes();
|
|
262
|
+
let clearedCount = 0;
|
|
263
|
+
let preservedCount = 0;
|
|
264
|
+
try {
|
|
265
|
+
// Clear fetch cache (data cache - always clearable)
|
|
266
|
+
clearedCount += await clearFetchCache(fetchCacheDir);
|
|
267
|
+
// Clear route cache (skip static routes)
|
|
268
|
+
const routeResult = await clearRouteCache(routeCacheDir, staticRoutes);
|
|
269
|
+
clearedCount += routeResult.cleared;
|
|
270
|
+
preservedCount = routeResult.preserved;
|
|
271
|
+
// Clear tags mapping
|
|
272
|
+
await clearTagsMapping(tagsFilePath);
|
|
273
|
+
fileLog.info(`Total cleared: ${clearedCount} cache entries`);
|
|
274
|
+
return clearedCount;
|
|
275
|
+
}
|
|
276
|
+
catch (error) {
|
|
277
|
+
fileLog.error('Error clearing cache directories:', error);
|
|
278
|
+
return 0;
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
async function clearFetchCache(dir) {
|
|
282
|
+
try {
|
|
283
|
+
const files = await fs.promises.readdir(dir);
|
|
284
|
+
const jsonFiles = files.filter((file) => file.endsWith('.json'));
|
|
285
|
+
for (const file of jsonFiles) {
|
|
286
|
+
await fs.promises.unlink(path.join(dir, file));
|
|
287
|
+
}
|
|
288
|
+
fileLog.debug(`Cleared ${jsonFiles.length} fetch cache entries`);
|
|
289
|
+
return jsonFiles.length;
|
|
290
|
+
}
|
|
291
|
+
catch {
|
|
292
|
+
return 0;
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
async function clearRouteCache(dir, staticRoutes) {
|
|
296
|
+
let cleared = 0;
|
|
297
|
+
let preserved = 0;
|
|
298
|
+
try {
|
|
299
|
+
const files = await fs.promises.readdir(dir);
|
|
300
|
+
const jsonFiles = files.filter((file) => file.endsWith('.json'));
|
|
301
|
+
for (const file of jsonFiles) {
|
|
302
|
+
const cacheKey = file.replace('.json', '');
|
|
303
|
+
if (staticRoutes.has(cacheKey)) {
|
|
304
|
+
preserved++;
|
|
305
|
+
continue;
|
|
306
|
+
}
|
|
307
|
+
await fs.promises.unlink(path.join(dir, file));
|
|
308
|
+
cleared++;
|
|
309
|
+
}
|
|
310
|
+
fileLog.debug(`Route cache: cleared ${cleared}, preserved ${preserved} static routes`);
|
|
311
|
+
}
|
|
312
|
+
catch {
|
|
313
|
+
// Directory might not exist
|
|
314
|
+
}
|
|
315
|
+
return { cleared, preserved };
|
|
316
|
+
}
|
|
317
|
+
async function clearTagsMapping(tagsFilePath) {
|
|
318
|
+
try {
|
|
319
|
+
const exists = await fs.promises
|
|
320
|
+
.access(tagsFilePath)
|
|
321
|
+
.then(() => true)
|
|
322
|
+
.catch(() => false);
|
|
323
|
+
if (exists) {
|
|
324
|
+
await fs.promises.unlink(tagsFilePath);
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
catch {
|
|
328
|
+
// Ignore errors
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
export default FileCacheHandler;
|
|
332
|
+
//# sourceMappingURL=file.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file.js","sourceRoot":"","sources":["../../src/handlers/file.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OA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AAE,CAAC,CAAC;YAE3C,IAAI,YAAY,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC;gBAC/B,SAAS,EAAE,CAAC;gBACZ,SAAS;YACX,CAAC;YAED,MAAM,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC;YAC/C,OAAO,EAAE,CAAC;QACZ,CAAC;QAED,OAAO,CAAC,KAAK,CAAC,wBAAwB,OAAO,eAAe,SAAS,gBAAgB,CAAC,CAAC;IACzF,CAAC;IAAC,MAAM,CAAC;QACP,4BAA4B;IAC9B,CAAC;IAED,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC;AAChC,CAAC;AAED,KAAK,UAAU,gBAAgB,CAAC,YAAoB;IAClD,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,EAAE,CAAC,QAAQ;aAC7B,MAAM,CAAC,YAAY,CAAC;aACpB,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC;aAChB,KAAK,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC;QACtB,IAAI,MAAM,EAAE,CAAC;YACX,MAAM,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;QACzC,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,gBAAgB;IAClB,CAAC;AACH,CAAC;AAED,eAAe,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { CacheStats, CacheHandlerValue, FileSystemCacheContext } from '../types.js';
|
|
2
|
+
import { BaseCacheHandler, type BuildMeta } from './base.js';
|
|
3
|
+
/**
|
|
4
|
+
* Google Cloud Storage cache handler for production/Pantheon environments.
|
|
5
|
+
* Stores cache entries in a GCS bucket.
|
|
6
|
+
*/
|
|
7
|
+
export declare class GcsCacheHandler extends BaseCacheHandler {
|
|
8
|
+
private readonly bucket;
|
|
9
|
+
private readonly fetchCachePrefix;
|
|
10
|
+
private readonly routeCachePrefix;
|
|
11
|
+
private readonly buildMetaKey;
|
|
12
|
+
private readonly tagsPrefix;
|
|
13
|
+
private readonly tagsMapKey;
|
|
14
|
+
private readonly edgeCacheClearer;
|
|
15
|
+
private readonly tagsBuffer;
|
|
16
|
+
constructor(context: FileSystemCacheContext);
|
|
17
|
+
protected initializeTagsMapping(): Promise<void>;
|
|
18
|
+
/**
|
|
19
|
+
* Read tags mapping, flushing any pending updates first to ensure accuracy.
|
|
20
|
+
*/
|
|
21
|
+
protected readTagsMapping(): Promise<Record<string, string[]>>;
|
|
22
|
+
/**
|
|
23
|
+
* Direct read from GCS without flushing buffer.
|
|
24
|
+
* Used internally by the buffer.
|
|
25
|
+
*/
|
|
26
|
+
private readTagsMappingDirect;
|
|
27
|
+
/**
|
|
28
|
+
* Write tags mapping directly to GCS.
|
|
29
|
+
* Used by the buffer for batched writes.
|
|
30
|
+
*/
|
|
31
|
+
protected writeTagsMapping(tagsMapping: Record<string, string[]>): Promise<void>;
|
|
32
|
+
/**
|
|
33
|
+
* Override to use buffered updates instead of immediate writes.
|
|
34
|
+
*/
|
|
35
|
+
protected updateTagsMapping(cacheKey: string, tags: string[], isDelete?: boolean): Promise<void>;
|
|
36
|
+
/**
|
|
37
|
+
* Override to use buffered deletes instead of immediate writes.
|
|
38
|
+
*/
|
|
39
|
+
protected updateTagsMappingBulkDelete(cacheKeysToDelete: string[], _tagsMapping: Record<string, string[]>): Promise<void>;
|
|
40
|
+
private getCacheKey;
|
|
41
|
+
protected readCacheEntry(cacheKey: string, cacheType: 'fetch' | 'route'): Promise<CacheHandlerValue | null>;
|
|
42
|
+
protected writeCacheEntry(cacheKey: string, cacheValue: CacheHandlerValue, cacheType: 'fetch' | 'route'): Promise<void>;
|
|
43
|
+
protected deleteCacheEntry(cacheKey: string, cacheType: 'fetch' | 'route'): Promise<void>;
|
|
44
|
+
protected readBuildMeta(): Promise<BuildMeta>;
|
|
45
|
+
protected writeBuildMeta(meta: BuildMeta): Promise<void>;
|
|
46
|
+
protected invalidateRouteCache(): Promise<void>;
|
|
47
|
+
private clearEdgeCache;
|
|
48
|
+
protected onRevalidateComplete(tags: string[], deletedKeys: string[]): Promise<void>;
|
|
49
|
+
/**
|
|
50
|
+
* Called when a route cache entry is set (ISR page update).
|
|
51
|
+
* Clears the edge cache for this specific route so users get the fresh version.
|
|
52
|
+
*/
|
|
53
|
+
protected onRouteCacheSet(cacheKey: string): void;
|
|
54
|
+
private cacheKeyToRoutePath;
|
|
55
|
+
private extractRoutePaths;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Get cache statistics for the GCS-based cache.
|
|
59
|
+
*/
|
|
60
|
+
export declare function getSharedCacheStats(): Promise<CacheStats>;
|
|
61
|
+
/**
|
|
62
|
+
* Clear all cache entries for the GCS-based cache.
|
|
63
|
+
*/
|
|
64
|
+
export declare function clearSharedCache(): Promise<number>;
|
|
65
|
+
export default GcsCacheHandler;
|
|
66
|
+
//# sourceMappingURL=gcs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gcs.d.ts","sourceRoot":"","sources":["../../src/handlers/gcs.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,UAAU,EAEV,iBAAiB,EACjB,sBAAsB,EACvB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,gBAAgB,EAAE,KAAK,SAAS,EAAE,MAAM,WAAW,CAAC;AAQ7D;;;GAGG;AACH,qBAAa,eAAgB,SAAQ,gBAAgB;IACnD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAS;IAC1C,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAS;IAC1C,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAS;IACtC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAS;IACpC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAS;IACpC,OAAO,CAAC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