Baktabek commited on
Commit
bb44b67
·
verified ·
1 Parent(s): 64de372

Add NoOpCache fallback

Browse files
app/infrastructure/cache/noop_cache.py ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Infrastructure - No-Op Cache (Fallback when Redis unavailable)
3
+ """
4
+ from typing import Any, Optional
5
+
6
+ from app.domain.interfaces import ICache
7
+
8
+
9
+ class NoOpCache(ICache):
10
+ """No-operation cache - does nothing (fallback)"""
11
+
12
+ async def get(self, key: str) -> Optional[Any]:
13
+ """Always return None (cache miss)"""
14
+ return None
15
+
16
+ async def set(self, key: str, value: Any, ttl: Optional[int] = None) -> bool:
17
+ """Do nothing, return True"""
18
+ return True
19
+
20
+ async def delete(self, key: str) -> bool:
21
+ """Do nothing, return True"""
22
+ return True
23
+
24
+ async def exists(self, key: str) -> bool:
25
+ """Always return False"""
26
+ return False
27
+
28
+ async def clear(self) -> bool:
29
+ """Do nothing, return True"""
30
+ return True