Mercurial
view asyncio_threads/bucket_questions/README.md @ 154:bdcc610eeed8
[Markdown Converter][GuiZe] Added markdown coverter in C and wasm rule sets. Needs further view on this as I haven't taken a look. Written by Claude.
| author | June Park <parkjune1995@gmail.com> |
|---|---|
| date | Mon, 12 Jan 2026 09:11:58 -0800 |
| parents | 46daba6e3cf4 |
| children |
line wrap: on
line source
# Bucket questions ## Context Please implement two functions: refillTokenBucket and useTokens. Two classes are already defined: DistributedCache and TokenBucket. refillTokenBucket(user_id): Refill tokens for the specified user's bucket. 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. ## Requirements Use the API provided by DistributedCache to get and update the user's TokenBucket. Implement the functionality using existing class instances and ensure the behavior is correct across multiple calls