fix: functions without 'return' are not cached
See original GitHub issueReproducible code sample
import asyncio
from cashews import cache
cache.setup("mem://")
@cache(ttl="10m")
async def get():
print("Start!")
await asyncio.sleep(2)
print("End!")
# return "foobar"
async def func():
await get()
await get()
asyncio.run(func())
Expected behavior
Functions without ‘return’ must be cached. The same as Python’s ‘functools.cache’ decorator works.
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
python optional caching of function - Stack Overflow
I've a function which performs a database request and does not take any arguments. Most of the times it's okay if the function...
Read more >cannot cache function that does not accept an argument #1390
Expected behavior: I expect the function to just be cached deterministically, as if I were using the lru_cache instead.
Read more >@lru_cache on functions with no arguments - Google Groups
1. The functions Django wants to cache require Django to be initialized and the settings loaded. This means the return values are not...
Read more >Memoizing recursive JavaScript functions (without mentioning ...
The trick here is that you're using side-effects. It's not possible to use your approach if the original function and the caching version...
Read more >Reading and writing data to the cache - Apollo GraphQL Docs
If the cache is missing data for any of the query's fields, readQuery returns null . It does not attempt to fetch data...
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
@AIGeneratedUsername Thanks for you input, I on the same side with you. And you mentioned case where prefer to do not cache None, and I thought that is is more safer behavior. And now I think that I was wrong.
I’ll fix it
Thanks - I enabled it, I am not familiar with it -let’s try