Skip to content

Temporal rooms (TTL) #311

@btzr-io

Description

@btzr-io

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 ? #25

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions