Mercurial
comparison asyncio_threads/bucket_questions/README.md @ 48:46daba6e3cf4
Few python scrtips to show how to use asychio.
| author | MrJuneJune <me@mrjunejune.com> |
|---|---|
| date | Sat, 13 Dec 2025 14:23:02 -0800 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 47:829623189a57 | 48:46daba6e3cf4 |
|---|---|
| 1 # Bucket questions | |
| 2 | |
| 3 ## Context | |
| 4 | |
| 5 Please implement two functions: refillTokenBucket and useTokens. Two classes are already defined: DistributedCache and TokenBucket. | |
| 6 | |
| 7 refillTokenBucket(user_id): Refill tokens for the specified user's bucket. | |
| 8 | |
| 9 useTokens(user_id, tokens): Check if there are enough tokens in the specified user's token bucket. If so, update the remaining token count and return true; otherwise, return false. You are required to use instances of the existing classes to implement these functions. | |
| 10 | |
| 11 ## Requirements | |
| 12 | |
| 13 Use the API provided by DistributedCache to get and update the user's TokenBucket. | |
| 14 Implement the functionality using existing class instances and ensure the behavior is correct across multiple calls |