Skip to content

Cache Enums

Enumeration types used across the cache package.

CacheBackendType

CacheBackendType

Bases: str, Enum

Supported cache backend types.

Source code in src/jinpy_utils/cache/enums.py
4
5
6
7
8
9
class CacheBackendType(str, Enum):
    """Supported cache backend types."""

    MEMORY = "memory"
    REDIS = "redis"
    FILE = "file"

CacheOperation

CacheOperation

Bases: str, Enum

Cache operations for context.

Source code in src/jinpy_utils/cache/enums.py
class CacheOperation(str, Enum):
    """Cache operations for context."""

    GET = "get"
    SET = "set"
    DELETE = "delete"
    EXISTS = "exists"
    INCR = "incr"
    DECR = "decr"
    CLEAR = "clear"
    GET_MANY = "get_many"
    SET_MANY = "set_many"
    DELETE_MANY = "delete_many"
    TTL = "ttl"
    TOUCH = "touch"
    CLOSE = "close"
    HEALTH = "health"

CacheErrorType

CacheErrorType

Bases: str, Enum

Error classifications for cache.

Source code in src/jinpy_utils/cache/enums.py
class CacheErrorType(str, Enum):
    """Error classifications for cache."""

    CONNECTION = "connection"
    SERIALIZATION = "serialization"
    KEY_ERROR = "key_error"
    TIMEOUT = "timeout"
    BACKEND_ERROR = "backend_error"
    CONFIGURATION = "configuration"
    OPERATION = "operation"

Examples

from jinpy_utils.cache import CacheBackendType, CacheOperation

if CacheBackendType.MEMORY == CacheBackendType("memory"):
    print("Using memory backend")

print(CacheOperation.GET.value)  # "get"