Skip to content

Commit ecf4b95

Browse files
committed
add a decorated version of BackendCommands and AsyncBackendCommands
1 parent 2b20ed7 commit ecf4b95

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
lines changed

django_valkey/async_cache/cache.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,21 @@
11
from valkey.asyncio.client import Valkey as AValkey
22

3-
from django_valkey.base import BaseValkeyCache, AsyncBackendCommands
3+
from django_valkey.base import (
4+
BaseValkeyCache,
5+
AsyncBackendCommands,
6+
decorate_all_methods,
7+
omit_exception,
8+
)
49
from django_valkey.async_cache.client.default import AsyncDefaultClient
510

611

12+
@decorate_all_methods(omit_exception)
13+
class DecoratedAsyncBackendCommands(AsyncBackendCommands):
14+
pass
15+
16+
717
class AsyncValkeyCache(
8-
BaseValkeyCache[AsyncDefaultClient, AValkey], AsyncBackendCommands
18+
BaseValkeyCache[AsyncDefaultClient, AValkey], DecoratedAsyncBackendCommands
919
):
1020
DEFAULT_CLIENT_CLASS = "django_valkey.async_cache.client.default.AsyncDefaultClient"
1121
is_async = True

django_valkey/cache.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,18 @@
11
from valkey import Valkey
22

3-
from django_valkey.base import BaseValkeyCache, BackendCommands
3+
from django_valkey.base import (
4+
BaseValkeyCache,
5+
BackendCommands,
6+
decorate_all_methods,
7+
omit_exception,
8+
)
49
from django_valkey.client import DefaultClient
510

611

7-
class ValkeyCache(BaseValkeyCache[DefaultClient, Valkey], BackendCommands):
12+
@decorate_all_methods(omit_exception)
13+
class DecoratedBackendCommands(BackendCommands):
14+
pass
15+
16+
17+
class ValkeyCache(BaseValkeyCache[DefaultClient, Valkey], DecoratedBackendCommands):
818
DEFAULT_CLIENT_CLASS = "django_valkey.client.DefaultClient"

0 commit comments

Comments
 (0)