Hi - I'm thinking of using KV to debounce a webhook - is there a way to trigger a worker when a valu
Hi - I'm thinking of using KV to debounce a webhook - is there a way to trigger a worker when a value with a TTL is deleted from KV?

typed-kv. npm i typed-kv. There are no other projects in the npm registry using typed-kv.
wrangler.tomlThe .ts file which has the .put

expires is set, in which case I'd assume it doesn't take long to disappear after), but not being able to 'GET' the value on a Pages Function, several days after it's already been put (and is shown on the dashboard), feels a lot like a bug and not a "that's how it is".wrangler.toml) on a Pages project (with a Function). I can see that when I run wrangler pages locally it binds correctly (if it didn't, it wouldn't be able to fetch any value anyway, but it can, albeit only one).list() and a consistent prefix - e.g. ${userId}-${urlId} so you can list all URLs by user - this may be tricky and lengthen your URLs.
typed-kvnpm i typed-kvwrangler.tomlwrangler.toml...
[[kv_namespaces]]
binding = "OAUTH_KV"
id = "..."
...The .ts file which has the .putname="pages-name"
pages_build_output_dir = "dist"
compatibility_date = "2024-06-12"
[[kv_namespaces]]
binding = "OAUTH_KV"
id = "..."
[dev]
port = 3000
[env.production]
[env.production.vars]
PUBLIC_ENVIRONMENT = "production"
SOME_VAR = "BLA BLA"
[env.preview]
[env.preview.vars]
PUBLIC_ENVIRONMENT = "preview"
SOME_VAR = "BLA BLA"expiresputlist()${userId}-${urlId}export const onRequestGet: PagesFunction<Env> = async ({ request, env }) => {
const { OAUTH_KV } = env;
...
try {
const dateStamp = new Date().toUTCString();
await OAUTH_KV.put(`smt:${user_id}`, longToken, {
expirationTtl: expiresIn,
metadata: {
"added_in": dateStamp,
},
});
console.log(`Stored long-lived token for user ${user_id}.`);
} catch (e) {
console.log(`Error storing smt long-lived token: ${e}`);
}