refactor: replace sync_to_async cache wrappers with native cache.aget/aset/adelete
This commit is contained in:
@@ -1,14 +1,13 @@
|
||||
from asgiref.sync import sync_to_async
|
||||
from django.core.cache import cache
|
||||
|
||||
|
||||
async def async_cache_get(key, default=None):
|
||||
return await sync_to_async(cache.get, thread_sensitive=True)(key, default)
|
||||
return await cache.aget(key, default)
|
||||
|
||||
|
||||
async def async_cache_set(key, value, timeout=None):
|
||||
return await sync_to_async(cache.set, thread_sensitive=True)(key, value, timeout)
|
||||
return await cache.aset(key, value, timeout)
|
||||
|
||||
|
||||
async def async_cache_delete(key):
|
||||
return await sync_to_async(cache.delete, thread_sensitive=True)(key)
|
||||
return await cache.adelete(key)
|
||||
|
||||
Reference in New Issue
Block a user