2024-07-05 14:38:26 +00:00
|
|
|
"""Defines the base constance backend."""
|
2010-12-01 17:13:37 +00:00
|
|
|
|
2026-03-04 22:37:37 +00:00
|
|
|
from abc import ABC
|
|
|
|
|
from abc import abstractmethod
|
2013-04-12 15:39:10 +00:00
|
|
|
|
2026-03-04 22:37:37 +00:00
|
|
|
|
|
|
|
|
class Backend(ABC):
|
|
|
|
|
@abstractmethod
|
2010-12-01 17:13:37 +00:00
|
|
|
def get(self, key):
|
|
|
|
|
"""
|
2010-12-11 15:38:40 +00:00
|
|
|
Get the key from the backend store and return the value.
|
2010-12-01 17:13:37 +00:00
|
|
|
Return None if not found.
|
|
|
|
|
"""
|
2026-03-04 22:37:37 +00:00
|
|
|
...
|
2010-12-01 17:13:37 +00:00
|
|
|
|
2026-03-04 22:37:37 +00:00
|
|
|
@abstractmethod
|
|
|
|
|
async def aget(self, key):
|
|
|
|
|
"""
|
|
|
|
|
Get the key from the backend store and return the value.
|
|
|
|
|
Return None if not found.
|
|
|
|
|
"""
|
|
|
|
|
...
|
|
|
|
|
|
|
|
|
|
@abstractmethod
|
2010-12-11 15:38:40 +00:00
|
|
|
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.
|
|
|
|
|
"""
|
2026-03-04 22:37:37 +00:00
|
|
|
...
|
2010-12-11 15:38:40 +00:00
|
|
|
|
2026-03-04 22:37:37 +00:00
|
|
|
@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
|
2010-12-01 17:13:37 +00:00
|
|
|
def set(self, key, value):
|
2024-07-05 14:38:26 +00:00
|
|
|
"""Add the value to the backend store given the key."""
|
2026-03-04 22:37:37 +00:00
|
|
|
...
|
|
|
|
|
|
|
|
|
|
@abstractmethod
|
|
|
|
|
async def aset(self, key, value):
|
|
|
|
|
"""Add the value to the backend store given the key."""
|
|
|
|
|
...
|