Skip to content

Commit 8237bb7

Browse files
committed
Specify surrogate key when caching index and settings, and purge it after publishing
1 parent 0a028db commit 8237bb7

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@ Optional:
5757
--root-dir=<dir> Directory to publish from. Overrides the config file setting.
5858
Default: rootDir from publish-content.config.js
5959
60+
--fastly-api-token=<token> Fastly API token for KV Store or cache access.
61+
If not set, the tool will check:
62+
1. FASTLY_API_TOKEN environment variable
63+
2. Logged-in Fastly CLI profile
64+
6065
--overwrite-existing Always overwrite existing entries in storage, even if unchanged.
6166
6267
Expiration:
@@ -76,11 +81,6 @@ KV Store Options:
7681
local files that will be used to simulate the KV Store
7782
with the local development environment.
7883
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-
8484
--kv-overwrite Alias for --overwrite-existing.
8585
8686
S3 Storage Options (BETA):
@@ -595,6 +595,8 @@ export async function action(actionArgs: string[]) {
595595

596596
console.log(`✅ Settings have been saved.`);
597597

598+
await storageProvider.purgeSurrogateKey(`${publishId}-${collectionName}`);
599+
598600
console.log(`🎉 Completed.`);
599601

600602
}

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)