13 Replies
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?
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
I see
CF has free rate limiting as well, but a bit restricted/limited on free plan
tysm
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
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
sorry, this is too hard to understand for non-native english like me
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