Skip to content

BaseCache

from pulsefire.caches import BaseCache 

Bases: ABC

Base cache class.

Inherit from this class to implement a cache.

Source code in pulsefire/caches.py
class BaseCache(abc.ABC):
    """Base cache class.

    Inherit from this class to implement a cache.
    """

    @abc.abstractmethod
    async def get[T](self, key: str) -> T:
        """Get a value from cache."""

    @abc.abstractmethod
    async def set(self, key: str, value: Any, ttl: float) -> None:
        """Set a value to cache."""

    @abc.abstractmethod
    async def clear(self) -> None:
        """Clear all values in cache."""
Functions
get abstractmethod async
get(key: str) -> T

Get a value from cache.

Source code in pulsefire/caches.py
@abc.abstractmethod
async def get[T](self, key: str) -> T:
    """Get a value from cache."""
set abstractmethod async
set(key: str, value: Any, ttl: float) -> None

Set a value to cache.

Source code in pulsefire/caches.py
@abc.abstractmethod
async def set(self, key: str, value: Any, ttl: float) -> None:
    """Set a value to cache."""
clear abstractmethod async
clear() -> None

Clear all values in cache.

Source code in pulsefire/caches.py
@abc.abstractmethod
async def clear(self) -> None:
    """Clear all values in cache."""