24 lines
484 B
Python
24 lines
484 B
Python
from __future__ import annotations
|
|
|
|
from typing import Optional
|
|
|
|
|
|
class CacheBase:
|
|
"""缓存接口"""
|
|
|
|
def get(self, key: str) -> Optional[str]:
|
|
raise NotImplementedError
|
|
|
|
def set(self, key: str, value: str, ttl: int) -> None:
|
|
raise NotImplementedError
|
|
|
|
|
|
class NoopCache(CacheBase):
|
|
"""空实现缓存"""
|
|
|
|
def get(self, key: str) -> Optional[str]:
|
|
return None
|
|
|
|
def set(self, key: str, value: str, ttl: int) -> None:
|
|
return None
|