Durable object TTL/Expiration

is it possible to do this?
13 Replies
Chaika
Chaika10mo 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 …
Rubi
RubiOP10mo ago
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
Chaika10mo 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
Rubi
RubiOP10mo ago
I see
Chaika
Chaika10mo ago
CF has free rate limiting as well, but a bit restricted/limited on free plan
Rubi
RubiOP10mo ago
tysm
Chaika
Chaika10mo 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
Rubi
RubiOP10mo ago
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
Chaika10mo 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.
Rubi
RubiOP10mo ago
expire after 25h after first value set
No description
Rubi
RubiOP10mo ago
sorry, this is too hard to understand for non-native english like me
Chaika
Chaika10mo 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
Rubi
RubiOP10mo ago
this!, a statement that can;t be multi-interpreted and much easier to understand tysm
Want results from more Discord servers?
Add your server