mirror of
https://github.com/long2ice/fastapi-cache.git
synced 2026-03-24 20:47:54 +00:00
Add in-memory support.
This commit is contained in:
@@ -1,11 +1,17 @@
|
||||
class FastAPICache:
|
||||
_backend = None
|
||||
_prefix = None
|
||||
_expire = None
|
||||
_init = False
|
||||
|
||||
@classmethod
|
||||
def init(cls, backend, prefix: str = ""):
|
||||
def init(cls, backend, prefix: str = "", expire: int = None):
|
||||
if cls._init:
|
||||
return
|
||||
cls._init = True
|
||||
cls._backend = backend
|
||||
cls._prefix = prefix
|
||||
cls._expire = expire
|
||||
|
||||
@classmethod
|
||||
def get_backend(cls):
|
||||
@@ -14,5 +20,8 @@ class FastAPICache:
|
||||
|
||||
@classmethod
|
||||
def get_prefix(cls):
|
||||
assert cls._prefix, "You must call init first!" # nosec: B101
|
||||
return cls._prefix
|
||||
|
||||
@classmethod
|
||||
def get_expire(cls):
|
||||
return cls._expire
|
||||
|
||||
Reference in New Issue
Block a user