Skip to content

Commit 9af2f8f

Browse files
committed
Specify surrogate key when caching index and settings, and purge it after publishing
1 parent 2f97a16 commit 9af2f8f

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

src/cli/commands/manage/publish-content.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@ Description:
4747
will see the updated index of files and updated server settings from the
4848
publish-content.config.js file.
4949
50+
Required
51+
--fastly-api-token=<token> Fastly API token for KV Store or cache access.
52+
If not set, the tool will check:
53+
1. FASTLY_API_TOKEN environment variable
54+
2. Logged-in Fastly CLI profile
55+
5056
Optional:
5157
--collection-name=<name> Name of the collection to publish into.
5258
Default: value from static-publisher.rc.js (defaultCollectionName)
@@ -76,11 +82,6 @@ KV Store Options:
7682
local files that will be used to simulate the KV Store
7783
with the local development environment.
7884
79-
--fastly-api-token=<token> Fastly API token for KV Store access.
80-
If not set, the tool will check:
81-
1. FASTLY_API_TOKEN environment variable
82-
2. Logged-in Fastly CLI profile
83-
8485
--kv-overwrite Alias for --overwrite-existing.
8586
8687
S3 Storage Options (BETA):
@@ -595,6 +596,8 @@ export async function action(actionArgs: string[]) {
595596

596597
console.log(`✅ Settings have been saved.`);
597598

599+
await storageProvider.purgeSurrogateKey(`${publishId}-${collectionName}`);
600+
598601
console.log(`🎉 Completed.`);
599602

600603
}

src/server/publisher-server/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ export class PublisherServer {
120120
return this.settingsCached;
121121
}
122122
const settingsFileKey = `${this.publishId}_settings_${this.activeCollectionName}`;
123-
const settingsFile = await this.storageProvider.getEntry(settingsFileKey);
123+
const settingsFile = await this.storageProvider.getEntry(settingsFileKey, [`${this.publishId}-${this.activeCollectionName}`, 'settings']);
124124
if (settingsFile == null) {
125125
console.error(`Settings File not found at ${settingsFileKey}.`);
126126
console.error(`You may need to publish your application.`);
@@ -156,7 +156,7 @@ export class PublisherServer {
156156
return this.assetEntryMapCache;
157157
}
158158
const indexFileKey = `${this.publishId}_index_${this.activeCollectionName}`;
159-
const indexFile = await this.storageProvider.getEntry(indexFileKey);
159+
const indexFile = await this.storageProvider.getEntry(indexFileKey, [`${this.publishId}-${this.activeCollectionName}`, 'index']);
160160
if (indexFile == null) {
161161
console.error(`Index File not found at ${indexFileKey}.`);
162162
console.error(`You may need to publish your application.`);

0 commit comments

Comments
 (0)