feat: add shared fund quote capability
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
"""基金行情短缓存适配器。缓存失败只影响性能,不阻塞外部行情查询。"""
|
||||
|
||||
from typing import Protocol
|
||||
|
||||
from app.infrastructure.memory_cache import CacheReadResult
|
||||
|
||||
|
||||
class FundQuoteCacheClient(Protocol):
|
||||
async def get(self, key: str) -> CacheReadResult: ...
|
||||
|
||||
async def set(self, key: str, value: str, ttl_seconds: int) -> bool: ...
|
||||
|
||||
|
||||
class FundQuoteCache:
|
||||
def __init__(self, client: FundQuoteCacheClient) -> None:
|
||||
self.client = client
|
||||
|
||||
async def get(self, key: str) -> CacheReadResult:
|
||||
return await self.client.get(key)
|
||||
|
||||
async def set(self, key: str, value: str, ttl_seconds: int) -> bool:
|
||||
return await self.client.set(key, value, ttl_seconds)
|
||||
Reference in New Issue
Block a user