Skip to content

Commit

Permalink
fix(api): introduce separate versions kv space (#943)
Browse files Browse the repository at this point in the history
* fix(api): introduce separate versions kv space

* Create polite-elephants-grab.md
  • Loading branch information
ayuhito committed Feb 15, 2024
1 parent 70138c4 commit ed72d85
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/polite-elephants-grab.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"api": patch
---

fix(api): introduce separate versions kv space
2 changes: 1 addition & 1 deletion api/metadata/src/stats/get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const getVersion = async (
env: Env,
ctx: ExecutionContext,
) => {
const value = await env.STATS.get<VersionResponse>(
const value = await env.VERSIONS.get<VersionResponse>(
METADATA_KEYS.version(id),
{
type: 'json',
Expand Down
2 changes: 1 addition & 1 deletion api/metadata/src/stats/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const updateVersion = async (

// Add to KV cache
ctx.waitUntil(
env.STATS.put(METADATA_KEYS.version(id), JSON.stringify(resp), {
env.VERSIONS.put(METADATA_KEYS.version(id), JSON.stringify(resp), {
expirationTtl: KV_TTL, // We want to expire these as we can't cron trigger these yet
}),
);
Expand Down
2 changes: 1 addition & 1 deletion api/metadata/worker-configuration.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
interface Env {
METADATA: KVNamespace;
STATS: KVNamespace;
VERSIONS: KVNamespace;
BUCKET: R2Bucket;

// Secrets
Expand Down
4 changes: 2 additions & 2 deletions api/metadata/wrangler.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ main = "src/worker.ts"
compatibility_date = "2023-05-27"

kv_namespaces = [
{ binding = "STATS", id = "f1bd4c1a63df46d894f8030079597982" },
{ binding = "VERSIONS", id = "722f0fadd97343ebb8a51c925d1d4316" },
{ binding = "METADATA", id = "49e9d329349446cf948f84af9828914f" },
]

Expand All @@ -15,4 +15,4 @@ logpush = true
workers_dev = false

[triggers]
crons = ["0 0 * * *"]
crons = ["0 */3 * * *"]

0 comments on commit ed72d85

Please sign in to comment.