alru_cache caches the created Task objects
See original GitHub issueThis test program prints Tasks: 101:
import asyncio
from async_lru import alru_cache
import random
@alru_cache(maxsize=100)
async def cached_test(arg):
return arg
async def main():
while True:
arg = random.random()
value = await cached_test(arg)
assert arg == value
print("Tasks: ", len(asyncio.Task.all_tasks()))
asyncio.run(main())
While it’s OK to wrap the coroutine in a Task, it is not OK to keep the Task around. It should be keeping only the arg and result in its cache, not the Task.
Issue Analytics
- State:
- Created 5 years ago
- Comments:10 (7 by maintainers)
Top Results From Across the Web
LRU Cache Implementation - GeeksforGeeks
Create a class LRUCache with declare a list of type int, an unordered map of type <int, list<int>>, and a variable to store...
Read more >Implement LRU Cache - Educative.io
To implement an LRU cache we use two data structures: a hashmap and a doubly linked list. A doubly linked list helps in...
Read more >LRU Cache Data Structure - Interview Cake
A Least Recently Used (LRU) Cache organizes items in order of use, allowing you to quickly identify which item hasn't been used for...
Read more >Implement Least Recently Used (LRU) Cache - EnjoyAlgorithms
The least recently used (LRU) cache is one of the popular caching strategies, which defines the policy to discard the least recently used...
Read more >lru-cache - npm
A cache object that deletes the least-recently-used items. Specify a max number of the most recently used items that you want to keep,...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Should be fixed by https://pypi.org/project/async_lru/ 1.0.2 release
Hmm there might be a small
"typo"https://github.com/aio-libs/async_lru/pull/83 Give me some time to debug, that PR fixes Your issue