|
1 | 1 | from valkey.asyncio.client import Valkey as AValkey
|
2 | 2 |
|
3 |
| -from django_valkey.base import BaseValkeyCache |
4 |
| -from django_valkey.cache import omit_exception, CONNECTION_INTERRUPTED |
| 3 | +from django_valkey.base import BaseValkeyCache, AsyncBackendCommands |
5 | 4 | from django_valkey.async_cache.client.default import AsyncDefaultClient
|
6 | 5 |
|
7 | 6 |
|
8 |
| -class AsyncValkeyCache(BaseValkeyCache[AsyncDefaultClient, AValkey]): |
| 7 | +class AsyncValkeyCache( |
| 8 | + BaseValkeyCache[AsyncDefaultClient, AValkey], AsyncBackendCommands |
| 9 | +): |
9 | 10 | DEFAULT_CLIENT_CLASS = "django_valkey.async_cache.client.default.AsyncDefaultClient"
|
10 |
| - |
11 |
| - mset = BaseValkeyCache.amset |
12 |
| - |
13 |
| - keys = BaseValkeyCache.akeys |
14 |
| - |
15 |
| - iter_keys = BaseValkeyCache.aiter_keys |
16 |
| - |
17 |
| - ttl = BaseValkeyCache.attl |
18 |
| - |
19 |
| - pttl = BaseValkeyCache.apttl |
20 |
| - |
21 |
| - persist = BaseValkeyCache.apersist |
22 |
| - |
23 |
| - expire = BaseValkeyCache.aexpire |
24 |
| - |
25 |
| - expire_at = BaseValkeyCache.aexpire_at |
26 |
| - |
27 |
| - pexpire = BaseValkeyCache.apexpire |
28 |
| - |
29 |
| - pexpire_at = BaseValkeyCache.apexpire_at |
30 |
| - |
31 |
| - lock = alock = get_lock = BaseValkeyCache.aget_lock |
32 |
| - |
33 |
| - sadd = BaseValkeyCache.asadd |
34 |
| - |
35 |
| - scard = BaseValkeyCache.ascard |
36 |
| - |
37 |
| - sdiff = BaseValkeyCache.asdiff |
38 |
| - |
39 |
| - sdiffstore = BaseValkeyCache.asdiffstore |
40 |
| - |
41 |
| - sinter = BaseValkeyCache.asinter |
42 |
| - |
43 |
| - sinterstore = BaseValkeyCache.asinterstore |
44 |
| - |
45 |
| - sismember = BaseValkeyCache.asismember |
46 |
| - |
47 |
| - smembers = BaseValkeyCache.asmembers |
48 |
| - |
49 |
| - smove = BaseValkeyCache.asmove |
50 |
| - |
51 |
| - spop = BaseValkeyCache.aspop |
52 |
| - |
53 |
| - srandmember = BaseValkeyCache.asrandmember |
54 |
| - |
55 |
| - srem = BaseValkeyCache.asrem |
56 |
| - |
57 |
| - sscan = BaseValkeyCache.asscan |
58 |
| - |
59 |
| - sscan_iter = BaseValkeyCache.asscan_iter |
60 |
| - |
61 |
| - smismember = BaseValkeyCache.asmismember |
62 |
| - |
63 |
| - sunion = BaseValkeyCache.asunion |
64 |
| - |
65 |
| - sunionstore = BaseValkeyCache.asunionstore |
66 |
| - |
67 |
| - hset = BaseValkeyCache.ahset |
68 |
| - |
69 |
| - hdel = BaseValkeyCache.ahdel |
70 |
| - |
71 |
| - hlen = BaseValkeyCache.ahlen |
72 |
| - |
73 |
| - hkeys = BaseValkeyCache.ahkeys |
74 |
| - |
75 |
| - hexists = BaseValkeyCache.ahexists |
76 |
| - |
77 |
| - @omit_exception |
78 |
| - async def set(self, *args, **kwargs): |
79 |
| - return await self.client.aset(*args, **kwargs) |
80 |
| - |
81 |
| - aset = set |
82 |
| - |
83 |
| - @omit_exception |
84 |
| - async def incr_version(self, *args, **kwargs): |
85 |
| - return await self.client.aincr_version(*args, **kwargs) |
86 |
| - |
87 |
| - aincr_version = incr_version |
88 |
| - |
89 |
| - @omit_exception |
90 |
| - async def add(self, *args, **kwargs): |
91 |
| - return await self.client.aadd(*args, **kwargs) |
92 |
| - |
93 |
| - aadd = add |
94 |
| - |
95 |
| - async def get(self, key, default=None, version=None, client=None): |
96 |
| - value = await self._get(key, default, version, client) |
97 |
| - if value is CONNECTION_INTERRUPTED: |
98 |
| - value = default |
99 |
| - return value |
100 |
| - |
101 |
| - aget = get |
102 |
| - |
103 |
| - @omit_exception(return_value=CONNECTION_INTERRUPTED) |
104 |
| - async def _get(self, key, default=None, version=None, client=None): |
105 |
| - return await self.client.aget(key, default, version, client) |
106 |
| - |
107 |
| - async def delete(self, *args, **kwargs): |
108 |
| - result = await self.client.adelete(*args, **kwargs) |
109 |
| - return bool(result) |
110 |
| - |
111 |
| - adelete = delete |
112 |
| - |
113 |
| - @omit_exception |
114 |
| - async def delete_many(self, *args, **kwargs): |
115 |
| - return await self.client.adelete_many(*args, **kwargs) |
116 |
| - |
117 |
| - adelete_many = delete_many |
118 |
| - |
119 |
| - @omit_exception |
120 |
| - async def clear(self): |
121 |
| - return await self.client.aclear() |
122 |
| - |
123 |
| - aclear = clear |
124 |
| - |
125 |
| - @omit_exception(return_value={}) |
126 |
| - async def get_many(self, *args, **kwargs): |
127 |
| - return await self.client.aget_many(*args, **kwargs) |
128 |
| - |
129 |
| - aget_many = get_many |
130 |
| - |
131 |
| - @omit_exception |
132 |
| - async def set_many(self, *args, **kwargs): |
133 |
| - return await self.client.aset_many(*args, **kwargs) |
134 |
| - |
135 |
| - aset_many = set_many |
136 |
| - |
137 |
| - @omit_exception |
138 |
| - async def incr(self, *args, **kwargs): |
139 |
| - return await self.client.aincr(*args, **kwargs) |
140 |
| - |
141 |
| - aincr = incr |
142 |
| - |
143 |
| - @omit_exception |
144 |
| - async def decr(self, *args, **kwargs): |
145 |
| - return await self.client.adecr(*args, **kwargs) |
146 |
| - |
147 |
| - adecr = decr |
148 |
| - |
149 |
| - @omit_exception |
150 |
| - async def has_key(self, *args, **kwargs): |
151 |
| - return await self.client.ahas_key(*args, **kwargs) |
152 |
| - |
153 |
| - ahas_key = has_key |
154 |
| - |
155 |
| - @omit_exception |
156 |
| - async def aclose(self, *args, **kwargs): |
157 |
| - return await self.client.aclose() |
158 |
| - |
159 |
| - @omit_exception |
160 |
| - async def touch(self, *args, **kwargs): |
161 |
| - return await self.client.touch(*args, **kwargs) |
162 |
| - |
163 |
| - atouch = touch |
0 commit comments