Skip to content

CacheMode

Bases: Enum

WSDL caching strategies for ONVIF client performance optimization.

Different caching modes provide trade-offs between performance, memory usage, and disk storage. Choose based on the application's requirements.

Attributes:

Name Type Description
NONE Literal['none']

No caching; WSDL and XSD documents are fetched fresh.

MEM Literal['mem']

In-memory caching for the lifetime of the process.

DB Literal['db']

Persistent SQLite caching across process restarts.

Version History

Source code in onvif\operator.py
class CacheMode(Enum):
    """WSDL caching strategies for ONVIF client performance optimization.

    Different caching modes provide trade-offs between performance, memory usage,
    and disk storage. Choose based on the application's requirements.

    Attributes:
        NONE (Literal['none']): No caching; WSDL and XSD documents are fetched fresh.
        MEM (Literal['mem']): In-memory caching for the lifetime of the process.
        DB (Literal['db']): Persistent SQLite caching across process restarts.

    !!! tip "Version History"
        - Available since [`>=v0.0.1`](/onvif-python/releases/#v0.0.1) (first release).
        - Removed in [`>=v0.4.0`](/onvif-python/releases/#v0.4.0): `CacheMode.ALL`
    """

    NONE = "none"
    """
    No cache.

    Uses Zeep's default transport without a cache backend.

    :material-check-circle:{ .success } Simplest configuration

    :material-alert-circle:{ .danger } WSDL/XSD documents are fetched without caching

    !!! danger "Use case"
        Debugging, testing, and situations where fresh WSDL/XSD documents
        are required.
    """

    MEM = "mem"
    """
    In-memory cache.

    Uses Zeep's `InMemoryCache` (`zeep.cache.InMemoryCache`) backend.

    :material-check-circle:{ .success } Fast process-local WSDL/XSD reuse

    :material-check-circle:{ .success } No disk I/O

    :material-alert-circle:{ .danger } Cache is lost when the process exits

    !!! danger "Use case"
        Long-running applications, temporary sessions, and applications
        where persistent cache storage is not required.
    """

    DB = "db"
    """
    Persistent SQLite cache.

    Uses Zeep's `SqliteCache` (`zeep.cache.SqliteCache`) backend.

    :material-check-circle:{ .success } Persistent across process restarts

    :material-check-circle:{ .success } Reduces repeated WSDL/XSD downloads

    :material-alert-circle:{ .danger } Requires disk I/O and a writable cache directory

    !!! danger "Use case"
        Production applications, CLI tools, and environments where
        WSDL/XSD caching should persist across restarts.
    """

NONE = 'none' class-attribute instance-attribute

No cache.

Uses Zeep's default transport without a cache backend.

Simplest configuration

WSDL/XSD documents are fetched without caching

Use case

Debugging, testing, and situations where fresh WSDL/XSD documents are required.

MEM = 'mem' class-attribute instance-attribute

In-memory cache.

Uses Zeep's InMemoryCache (zeep.cache.InMemoryCache) backend.

Fast process-local WSDL/XSD reuse

No disk I/O

Cache is lost when the process exits

Use case

Long-running applications, temporary sessions, and applications where persistent cache storage is not required.

DB = 'db' class-attribute instance-attribute

Persistent SQLite cache.

Uses Zeep's SqliteCache (zeep.cache.SqliteCache) backend.

Persistent across process restarts

Reduces repeated WSDL/XSD downloads

Requires disk I/O and a writable cache directory

Use case

Production applications, CLI tools, and environments where WSDL/XSD caching should persist across restarts.