mirror of
https://github.com/jazzband/django-constance.git
synced 2026-03-16 22:40:24 +00:00
Some checks failed
Docs / docs (push) Has been cancelled
Test / ruff-format (push) Has been cancelled
Test / ruff-lint (push) Has been cancelled
Test / build (3.10) (push) Has been cancelled
Test / build (3.11) (push) Has been cancelled
Test / build (3.12) (push) Has been cancelled
Test / build (3.13) (push) Has been cancelled
Test / build (3.14) (push) Has been cancelled
Test / build (3.8) (push) Has been cancelled
Test / build (3.9) (push) Has been cancelled
* Added async logic * Added tests and fixed async deadlock on aset * Used abstract base class for backend to simplify code coverage * Reordered try except block * Added explicit thread safety * Fixed linting error * Worked on redis init block * Fixed async test setup * Added tests for redis instantiation * Fixed linting errors
48 lines
1.1 KiB
Python
48 lines
1.1 KiB
Python
"""Defines the base constance backend."""
|
|
|
|
from abc import ABC
|
|
from abc import abstractmethod
|
|
|
|
|
|
class Backend(ABC):
|
|
@abstractmethod
|
|
def get(self, key):
|
|
"""
|
|
Get the key from the backend store and return the value.
|
|
Return None if not found.
|
|
"""
|
|
...
|
|
|
|
@abstractmethod
|
|
async def aget(self, key):
|
|
"""
|
|
Get the key from the backend store and return the value.
|
|
Return None if not found.
|
|
"""
|
|
...
|
|
|
|
@abstractmethod
|
|
def mget(self, keys):
|
|
"""
|
|
Get the keys from the backend store and return a list of the values.
|
|
Return an empty list if not found.
|
|
"""
|
|
...
|
|
|
|
@abstractmethod
|
|
async def amget(self, keys):
|
|
"""
|
|
Get the keys from the backend store and return a list of the values.
|
|
Return an empty list if not found.
|
|
"""
|
|
...
|
|
|
|
@abstractmethod
|
|
def set(self, key, value):
|
|
"""Add the value to the backend store given the key."""
|
|
...
|
|
|
|
@abstractmethod
|
|
async def aset(self, key, value):
|
|
"""Add the value to the backend store given the key."""
|
|
...
|