cloudflare / cloudflare/partykit
Temporal rooms (TTL)
- Dominant language
- TypeScript
- Stars
- 1.3k
- Forks
- 79
- PR merge metrics
- No merged PRs in 30d
Description
Are there any examples or documentation on creating temporal rooms with a Time to Live option ?
> It differs in a specific way: There's no "terminate" handler, because a Durable Object can "shut down" / get evicted at any time, and we can't reliably call a "terminate" handler. Instead, you can set an alarm to run some cleanup code at some point in the future.
For the TTL feature I added a schedule alarm to trigger a cleanup function as suggested on the docs:
```
async cleanup () {
await this.ctx.storage.deleteAlarm();
await this.ctx.storage.deleteAll();
}
```
I'm still unsure how to force an eviction or actually delete the room if possible.
Related issue ? https://github.com/cloudflare/partykit/issues/25
Contributor guide
Assessment
This issue has not been assessed yet.