mirror of
https://github.com/long2ice/fastapi-cache.git
synced 2026-03-25 04:57:54 +00:00
19 lines
468 B
Python
19 lines
468 B
Python
|
|
class FastAPICache:
|
||
|
|
_backend = None
|
||
|
|
_prefix = None
|
||
|
|
|
||
|
|
@classmethod
|
||
|
|
def init(cls, backend, prefix: str = ""):
|
||
|
|
cls._backend = backend
|
||
|
|
cls._prefix = prefix
|
||
|
|
|
||
|
|
@classmethod
|
||
|
|
def get_backend(cls):
|
||
|
|
assert cls._backend, "You must call init first!" # nosec: B101
|
||
|
|
return cls._backend
|
||
|
|
|
||
|
|
@classmethod
|
||
|
|
def get_prefix(cls):
|
||
|
|
assert cls._prefix, "You must call init first!" # nosec: B101
|
||
|
|
return cls._prefix
|