Overwriting KV ttl?

Cloudflare KV has an expiry option, but if I rewrite that key with a different ttl, will it change? I want to make it so that after 30 days of inactivity, a key gets deleted, but if it is written to within the 30 days, the “deadline” gets pushed into the future. So, an “active” key would last forever, but an inactive would be deleted after 30 days of inactivity. Thanks.

Yes, NAMESPACE.put(key, value, expirationTtl: secondsFromNow}) will push the expire date forward.
This has the cost of a read and a write.

1 Like

Perfect, thanks!

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.