cloudflare / cloudflare/partykit

Temporal rooms (TTL)

Open
#311 0 comments 0 reactions 0 assignees View on GitHub
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.