Durable object TTL/Expiration

is it possible to do this?
13 Replies
Chaika
Chaikaβ€’4mo ago
You want to delete data after a time or so? If so, sounds like you're looking for Durable Object Alarms https://developers.cloudflare.com/durable-objects/api/alarms/
Cloudflare Docs
Alarms Β· Cloudflare Durable Objects docs
Durable Objects alarms allow you to schedule the Durable Object to be woken up at a time in the future. When the alarm’s scheduled time comes, the …
β„π•¦π•“π•š
WOW NICEEE ❀️ ILOVE CLOUDFLARE :MeowHeartCloudflare: :MeowHeartCloudflare: :MeowHeartCloudflare: :MeowHeartCloudflare: :MeowHeartCloudflare: :MeowHeartCloudflare: anyway, should I use DO or KV for rate limiting feature on my API Gateway?
Chaika
Chaikaβ€’4mo ago
DOs would be a better fit. KV is eventually consistent, has limits on how much you should update it (one write per key per second iirc), and more expensive
Chaika
Chaikaβ€’4mo ago
CF has free rate limiting as well, but a bit restricted/limited on free plan
Chaika
Chaikaβ€’4mo ago
There is examples out there of using DOs to do rate limiting: https://github.com/honzabit/durable-limiter
GitHub
GitHub - honzabit/durable-limiter: A rate-limiter using Durable Obj...
A rate-limiter using Durable Objects on CF Workers that actually doesn't rate limit anything. - honzabit/durable-limiter
β„π•¦π•“π•š
yeah, I've been looking for this, but because of the description that actually doesn't rate limit anything. I afraid to use Durable Object
Chaika
Chaikaβ€’4mo ago
Read the readme
But it doesn't rate limit anything Yeah, that's the sad truth. The code is there to decide whether or not a request should be rate-limited, but currently, it just outputs the results in a JSON response. The reason is that this is how it's being used as part of another project I'm working on. That said, I think it's a good starting point as it would require minimal changes from you to send the right responses back.
β„π•¦π•“π•š
expire after 25h after first value set
No description
β„π•¦π•“π•š
sorry, this is too hard to understand for non-native english like me
Chaika
Chaikaβ€’4mo ago
Their repo is just an example of how you could implement rate limiting a Durable Object. If you wanted to use it, you would take it and add it into your own logic It says "it doesn't rate limit anything" because in their example it just returns the rate limiting info rather then actually rate limiting anything, but of course that could be changed
β„π•¦π•“π•š
this!, a statement that can;t be multi-interpreted and much easier to understand tysm