You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've just been pointed to your package by @dunglas after submitting a PR for rate limits to the api-platform/core package.
I like the look of your offering, as it's more complete than the PR I submitted to the api-platform/core, however I think that it could be improved to better handle race conditions.
In the RateLimitHandler you read from the cache, check, and update. You would be better of using a cache key that includes all the rate limit details, and a timeframe string for the desired timeframe, incrementing the cache (first trying to add it, but ignoring errors when it already exists), and then verifying whether the resulting value is greater than the rate limit. This avoids issues with the cache value being updated between the read & the write.
I'm happy to submit a PR to update, if you're happy with me doing so?
The text was updated successfully, but these errors were encountered:
Hi @toby-griffiths ,
yeah, current implementation doesn't handle race condition gracefully.
i'm very happy if you want to make this bundle much better :)
Hi there,
I've just been pointed to your package by @dunglas after submitting a PR for rate limits to the api-platform/core package.
I like the look of your offering, as it's more complete than the PR I submitted to the api-platform/core, however I think that it could be improved to better handle race conditions.
In the
RateLimitHandler
you read from the cache, check, and update. You would be better of using a cache key that includes all the rate limit details, and a timeframe string for the desired timeframe, incrementing the cache (first trying to add it, but ignoring errors when it already exists), and then verifying whether the resulting value is greater than the rate limit. This avoids issues with the cache value being updated between the read & the write.I'm happy to submit a PR to update, if you're happy with me doing so?
The text was updated successfully, but these errors were encountered: