exonware-xwsystem 0.0.1.409__py3-none-any.whl → 0.0.1.411__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- exonware/__init__.py +2 -2
- exonware/conf.py +10 -20
- exonware/xwsystem/__init__.py +6 -16
- exonware/xwsystem/caching/__init__.py +1 -1
- exonware/xwsystem/caching/base.py +16 -16
- exonware/xwsystem/caching/bloom_cache.py +5 -5
- exonware/xwsystem/caching/cache_manager.py +2 -2
- exonware/xwsystem/caching/conditional.py +4 -4
- exonware/xwsystem/caching/contracts.py +12 -12
- exonware/xwsystem/caching/decorators.py +2 -2
- exonware/xwsystem/caching/defs.py +1 -1
- exonware/xwsystem/caching/disk_cache.py +4 -4
- exonware/xwsystem/caching/distributed.py +1 -1
- exonware/xwsystem/caching/errors.py +1 -1
- exonware/xwsystem/caching/events.py +8 -8
- exonware/xwsystem/caching/eviction_strategies.py +9 -9
- exonware/xwsystem/caching/fluent.py +1 -1
- exonware/xwsystem/caching/integrity.py +1 -1
- exonware/xwsystem/caching/lfu_cache.py +24 -9
- exonware/xwsystem/caching/lfu_optimized.py +21 -21
- exonware/xwsystem/caching/lru_cache.py +14 -7
- exonware/xwsystem/caching/memory_bounded.py +8 -8
- exonware/xwsystem/caching/metrics_exporter.py +6 -6
- exonware/xwsystem/caching/observable_cache.py +1 -1
- exonware/xwsystem/caching/pluggable_cache.py +9 -9
- exonware/xwsystem/caching/rate_limiter.py +1 -1
- exonware/xwsystem/caching/read_through.py +6 -6
- exonware/xwsystem/caching/secure_cache.py +1 -1
- exonware/xwsystem/caching/serializable.py +3 -3
- exonware/xwsystem/caching/stats.py +7 -7
- exonware/xwsystem/caching/tagging.py +11 -11
- exonware/xwsystem/caching/ttl_cache.py +21 -6
- exonware/xwsystem/caching/two_tier_cache.py +5 -5
- exonware/xwsystem/caching/utils.py +3 -3
- exonware/xwsystem/caching/validation.py +1 -1
- exonware/xwsystem/caching/warming.py +9 -9
- exonware/xwsystem/caching/write_behind.py +5 -5
- exonware/xwsystem/cli/__init__.py +1 -1
- exonware/xwsystem/cli/args.py +10 -10
- exonware/xwsystem/cli/base.py +15 -15
- exonware/xwsystem/cli/colors.py +1 -1
- exonware/xwsystem/cli/console.py +1 -1
- exonware/xwsystem/cli/contracts.py +5 -5
- exonware/xwsystem/cli/defs.py +1 -1
- exonware/xwsystem/cli/errors.py +1 -1
- exonware/xwsystem/cli/progress.py +1 -1
- exonware/xwsystem/cli/prompts.py +1 -1
- exonware/xwsystem/cli/tables.py +7 -7
- exonware/xwsystem/config/__init__.py +1 -1
- exonware/xwsystem/config/base.py +14 -14
- exonware/xwsystem/config/contracts.py +22 -22
- exonware/xwsystem/config/defaults.py +2 -2
- exonware/xwsystem/config/defs.py +1 -1
- exonware/xwsystem/config/errors.py +2 -2
- exonware/xwsystem/config/logging.py +1 -1
- exonware/xwsystem/config/logging_setup.py +2 -2
- exonware/xwsystem/config/performance.py +7 -7
- exonware/xwsystem/config/performance_modes.py +20 -20
- exonware/xwsystem/config/version_manager.py +4 -4
- exonware/xwsystem/{http → http_client}/__init__.py +1 -1
- exonware/xwsystem/{http → http_client}/advanced_client.py +20 -20
- exonware/xwsystem/{http → http_client}/base.py +13 -13
- exonware/xwsystem/{http → http_client}/client.py +43 -43
- exonware/xwsystem/{http → http_client}/contracts.py +5 -5
- exonware/xwsystem/{http → http_client}/defs.py +2 -2
- exonware/xwsystem/{http → http_client}/errors.py +2 -2
- exonware/xwsystem/io/__init__.py +1 -1
- exonware/xwsystem/io/archive/__init__.py +1 -1
- exonware/xwsystem/io/archive/archive.py +5 -5
- exonware/xwsystem/io/archive/archive_files.py +8 -8
- exonware/xwsystem/io/archive/archivers.py +3 -3
- exonware/xwsystem/io/archive/base.py +17 -17
- exonware/xwsystem/io/archive/codec_integration.py +1 -1
- exonware/xwsystem/io/archive/compression.py +1 -1
- exonware/xwsystem/io/archive/formats/__init__.py +1 -1
- exonware/xwsystem/io/archive/formats/brotli_format.py +12 -9
- exonware/xwsystem/io/archive/formats/lz4_format.py +12 -9
- exonware/xwsystem/io/archive/formats/rar.py +12 -9
- exonware/xwsystem/io/archive/formats/sevenzip.py +12 -9
- exonware/xwsystem/io/archive/formats/squashfs_format.py +7 -7
- exonware/xwsystem/io/archive/formats/tar.py +8 -8
- exonware/xwsystem/io/archive/formats/wim_format.py +12 -9
- exonware/xwsystem/io/archive/formats/zip.py +8 -8
- exonware/xwsystem/io/archive/formats/zpaq_format.py +7 -7
- exonware/xwsystem/io/archive/formats/zstandard.py +12 -9
- exonware/xwsystem/io/base.py +17 -17
- exonware/xwsystem/io/codec/__init__.py +1 -1
- exonware/xwsystem/io/codec/base.py +261 -14
- exonware/xwsystem/io/codec/contracts.py +3 -6
- exonware/xwsystem/io/codec/registry.py +29 -29
- exonware/xwsystem/io/common/__init__.py +1 -1
- exonware/xwsystem/io/common/atomic.py +2 -2
- exonware/xwsystem/io/common/base.py +1 -1
- exonware/xwsystem/io/common/lock.py +1 -1
- exonware/xwsystem/io/common/watcher.py +4 -4
- exonware/xwsystem/io/contracts.py +34 -39
- exonware/xwsystem/io/data_operations.py +480 -0
- exonware/xwsystem/io/defs.py +2 -2
- exonware/xwsystem/io/errors.py +32 -3
- exonware/xwsystem/io/facade.py +4 -4
- exonware/xwsystem/io/file/__init__.py +1 -1
- exonware/xwsystem/io/file/base.py +2 -2
- exonware/xwsystem/io/file/conversion.py +1 -1
- exonware/xwsystem/io/file/file.py +10 -8
- exonware/xwsystem/io/file/paged_source.py +8 -1
- exonware/xwsystem/io/file/paging/__init__.py +1 -1
- exonware/xwsystem/io/file/paging/byte_paging.py +1 -1
- exonware/xwsystem/io/file/paging/line_paging.py +1 -1
- exonware/xwsystem/io/file/paging/record_paging.py +1 -1
- exonware/xwsystem/io/file/paging/registry.py +5 -5
- exonware/xwsystem/io/file/source.py +22 -11
- exonware/xwsystem/io/filesystem/__init__.py +1 -1
- exonware/xwsystem/io/filesystem/base.py +1 -1
- exonware/xwsystem/io/filesystem/local.py +9 -1
- exonware/xwsystem/io/folder/__init__.py +1 -1
- exonware/xwsystem/io/folder/base.py +2 -2
- exonware/xwsystem/io/folder/folder.py +6 -6
- exonware/xwsystem/io/serialization/__init__.py +1 -1
- exonware/xwsystem/io/serialization/auto_serializer.py +53 -40
- exonware/xwsystem/io/serialization/base.py +248 -35
- exonware/xwsystem/io/serialization/contracts.py +93 -4
- exonware/xwsystem/io/serialization/defs.py +1 -1
- exonware/xwsystem/io/serialization/errors.py +1 -1
- exonware/xwsystem/io/serialization/flyweight.py +22 -22
- exonware/xwsystem/io/serialization/format_detector.py +18 -15
- exonware/xwsystem/io/serialization/formats/__init__.py +1 -1
- exonware/xwsystem/io/serialization/formats/binary/bson.py +1 -1
- exonware/xwsystem/io/serialization/formats/binary/cbor.py +1 -1
- exonware/xwsystem/io/serialization/formats/binary/marshal.py +1 -1
- exonware/xwsystem/io/serialization/formats/binary/msgpack.py +1 -1
- exonware/xwsystem/io/serialization/formats/binary/pickle.py +1 -1
- exonware/xwsystem/io/serialization/formats/binary/plistlib.py +1 -1
- exonware/xwsystem/io/serialization/formats/database/dbm.py +53 -1
- exonware/xwsystem/io/serialization/formats/database/shelve.py +48 -1
- exonware/xwsystem/io/serialization/formats/database/sqlite3.py +85 -1
- exonware/xwsystem/io/serialization/formats/text/configparser.py +2 -2
- exonware/xwsystem/io/serialization/formats/text/csv.py +2 -2
- exonware/xwsystem/io/serialization/formats/text/formdata.py +2 -2
- exonware/xwsystem/io/serialization/formats/text/json.py +23 -5
- exonware/xwsystem/io/serialization/formats/text/json5.py +98 -13
- exonware/xwsystem/io/serialization/formats/text/jsonlines.py +230 -20
- exonware/xwsystem/io/serialization/formats/text/multipart.py +2 -2
- exonware/xwsystem/io/serialization/formats/text/toml.py +65 -4
- exonware/xwsystem/io/serialization/formats/text/xml.py +451 -69
- exonware/xwsystem/io/serialization/formats/text/yaml.py +52 -2
- exonware/xwsystem/io/serialization/registry.py +5 -5
- exonware/xwsystem/io/serialization/serializer.py +184 -12
- exonware/xwsystem/io/serialization/utils/__init__.py +1 -1
- exonware/xwsystem/io/serialization/utils/path_ops.py +3 -3
- exonware/xwsystem/io/stream/__init__.py +1 -1
- exonware/xwsystem/io/stream/async_operations.py +3 -3
- exonware/xwsystem/io/stream/base.py +3 -7
- exonware/xwsystem/io/stream/codec_io.py +4 -7
- exonware/xwsystem/ipc/async_fabric.py +7 -8
- exonware/xwsystem/ipc/base.py +9 -9
- exonware/xwsystem/ipc/contracts.py +5 -5
- exonware/xwsystem/ipc/defs.py +1 -1
- exonware/xwsystem/ipc/errors.py +2 -2
- exonware/xwsystem/ipc/message_queue.py +4 -6
- exonware/xwsystem/ipc/pipes.py +2 -2
- exonware/xwsystem/ipc/process_manager.py +7 -7
- exonware/xwsystem/ipc/process_pool.py +8 -8
- exonware/xwsystem/ipc/shared_memory.py +7 -7
- exonware/xwsystem/monitoring/base.py +33 -33
- exonware/xwsystem/monitoring/contracts.py +27 -27
- exonware/xwsystem/monitoring/defs.py +1 -1
- exonware/xwsystem/monitoring/error_recovery.py +16 -16
- exonware/xwsystem/monitoring/errors.py +2 -2
- exonware/xwsystem/monitoring/memory_monitor.py +12 -12
- exonware/xwsystem/monitoring/metrics.py +8 -8
- exonware/xwsystem/monitoring/performance_manager_generic.py +20 -20
- exonware/xwsystem/monitoring/performance_monitor.py +11 -11
- exonware/xwsystem/monitoring/performance_validator.py +21 -21
- exonware/xwsystem/monitoring/system_monitor.py +17 -17
- exonware/xwsystem/monitoring/tracing.py +20 -20
- exonware/xwsystem/monitoring/tracker.py +7 -7
- exonware/xwsystem/operations/__init__.py +5 -5
- exonware/xwsystem/operations/base.py +3 -3
- exonware/xwsystem/operations/contracts.py +3 -3
- exonware/xwsystem/operations/defs.py +5 -5
- exonware/xwsystem/operations/diff.py +5 -5
- exonware/xwsystem/operations/merge.py +2 -2
- exonware/xwsystem/operations/patch.py +5 -5
- exonware/xwsystem/patterns/base.py +4 -4
- exonware/xwsystem/patterns/context_manager.py +7 -7
- exonware/xwsystem/patterns/contracts.py +29 -31
- exonware/xwsystem/patterns/defs.py +1 -1
- exonware/xwsystem/patterns/dynamic_facade.py +9 -9
- exonware/xwsystem/patterns/errors.py +10 -10
- exonware/xwsystem/patterns/handler_factory.py +15 -14
- exonware/xwsystem/patterns/import_registry.py +22 -22
- exonware/xwsystem/patterns/object_pool.py +14 -13
- exonware/xwsystem/patterns/registry.py +45 -32
- exonware/xwsystem/plugins/__init__.py +1 -1
- exonware/xwsystem/plugins/base.py +25 -25
- exonware/xwsystem/plugins/contracts.py +28 -28
- exonware/xwsystem/plugins/defs.py +1 -1
- exonware/xwsystem/plugins/errors.py +9 -9
- exonware/xwsystem/runtime/__init__.py +1 -1
- exonware/xwsystem/runtime/base.py +42 -42
- exonware/xwsystem/runtime/contracts.py +9 -9
- exonware/xwsystem/runtime/defs.py +1 -1
- exonware/xwsystem/runtime/env.py +9 -9
- exonware/xwsystem/runtime/errors.py +1 -1
- exonware/xwsystem/runtime/reflection.py +15 -15
- exonware/xwsystem/security/auth.py +47 -15
- exonware/xwsystem/security/base.py +17 -17
- exonware/xwsystem/security/contracts.py +30 -30
- exonware/xwsystem/security/crypto.py +8 -8
- exonware/xwsystem/security/defs.py +1 -1
- exonware/xwsystem/security/errors.py +2 -2
- exonware/xwsystem/security/hazmat.py +7 -7
- exonware/xwsystem/security/path_validator.py +1 -1
- exonware/xwsystem/shared/__init__.py +1 -1
- exonware/xwsystem/shared/base.py +14 -14
- exonware/xwsystem/shared/contracts.py +6 -6
- exonware/xwsystem/shared/defs.py +1 -1
- exonware/xwsystem/shared/errors.py +1 -1
- exonware/xwsystem/structures/__init__.py +1 -1
- exonware/xwsystem/structures/base.py +29 -29
- exonware/xwsystem/structures/circular_detector.py +15 -15
- exonware/xwsystem/structures/contracts.py +9 -9
- exonware/xwsystem/structures/defs.py +1 -1
- exonware/xwsystem/structures/errors.py +2 -2
- exonware/xwsystem/structures/tree_walker.py +8 -8
- exonware/xwsystem/threading/async_primitives.py +7 -7
- exonware/xwsystem/threading/base.py +19 -19
- exonware/xwsystem/threading/contracts.py +13 -13
- exonware/xwsystem/threading/defs.py +1 -1
- exonware/xwsystem/threading/errors.py +2 -2
- exonware/xwsystem/threading/safe_factory.py +13 -12
- exonware/xwsystem/utils/base.py +34 -34
- exonware/xwsystem/utils/contracts.py +9 -9
- exonware/xwsystem/utils/dt/__init__.py +1 -1
- exonware/xwsystem/utils/dt/base.py +6 -6
- exonware/xwsystem/utils/dt/contracts.py +2 -2
- exonware/xwsystem/utils/dt/defs.py +1 -1
- exonware/xwsystem/utils/dt/errors.py +2 -2
- exonware/xwsystem/utils/dt/formatting.py +3 -3
- exonware/xwsystem/utils/dt/humanize.py +2 -2
- exonware/xwsystem/utils/dt/parsing.py +2 -2
- exonware/xwsystem/utils/dt/timezone_utils.py +5 -5
- exonware/xwsystem/utils/errors.py +2 -2
- exonware/xwsystem/utils/test_runner.py +6 -6
- exonware/xwsystem/utils/utils_contracts.py +1 -1
- exonware/xwsystem/validation/__init__.py +1 -1
- exonware/xwsystem/validation/base.py +48 -48
- exonware/xwsystem/validation/contracts.py +8 -8
- exonware/xwsystem/validation/data_validator.py +10 -0
- exonware/xwsystem/validation/declarative.py +15 -15
- exonware/xwsystem/validation/defs.py +1 -1
- exonware/xwsystem/validation/errors.py +2 -2
- exonware/xwsystem/validation/fluent_validator.py +10 -10
- exonware/xwsystem/version.py +2 -2
- {exonware_xwsystem-0.0.1.409.dist-info → exonware_xwsystem-0.0.1.411.dist-info}/METADATA +9 -11
- exonware_xwsystem-0.0.1.411.dist-info/RECORD +274 -0
- {exonware_xwsystem-0.0.1.409.dist-info → exonware_xwsystem-0.0.1.411.dist-info}/WHEEL +1 -1
- exonware/xwsystem/lazy_bootstrap.py +0 -79
- exonware_xwsystem-0.0.1.409.dist-info/RECORD +0 -274
- {exonware_xwsystem-0.0.1.409.dist-info → exonware_xwsystem-0.0.1.411.dist-info}/licenses/LICENSE +0 -0
exonware/__init__.py
CHANGED
|
@@ -4,14 +4,14 @@ exonware package - Enterprise-grade Python framework ecosystem
|
|
|
4
4
|
Company: eXonware.com
|
|
5
5
|
Author: Eng. Muhammad AlShehri
|
|
6
6
|
Email: connect@exonware.com
|
|
7
|
-
Version: 0.0.1.
|
|
7
|
+
Version: 0.0.1.411
|
|
8
8
|
Generation Date: September 04, 2025
|
|
9
9
|
|
|
10
10
|
This is a namespace package allowing multiple exonware subpackages
|
|
11
11
|
to coexist (xwsystem, xwnode, xwdata, etc.)
|
|
12
12
|
"""
|
|
13
13
|
|
|
14
|
-
# Make this a namespace package
|
|
14
|
+
# Make this a namespace package FIRST
|
|
15
15
|
__path__ = __import__('pkgutil').extend_path(__path__, __name__)
|
|
16
16
|
|
|
17
17
|
import importlib.metadata
|
exonware/conf.py
CHANGED
|
@@ -9,7 +9,7 @@ works across all exonware packages (xwsystem, xwnode, xwdata, etc.).
|
|
|
9
9
|
Company: eXonware.com
|
|
10
10
|
Author: Eng. Muhammad AlShehri
|
|
11
11
|
Email: connect@exonware.com
|
|
12
|
-
Version: 0.0.1.
|
|
12
|
+
Version: 0.0.1.411
|
|
13
13
|
Generation Date: 11-Nov-2025
|
|
14
14
|
"""
|
|
15
15
|
|
|
@@ -95,25 +95,15 @@ if sys.platform == "win32":
|
|
|
95
95
|
except Exception:
|
|
96
96
|
pass # Silently fail if wrapping is not possible
|
|
97
97
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
#
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
def __getattr__(self, name: str):
|
|
108
|
-
raise RuntimeError(
|
|
109
|
-
"Lazy configuration requires 'exonware-xwlazy'. "
|
|
110
|
-
"Install it via 'pip install exonware-xwlazy' to enable lazy mode."
|
|
111
|
-
)
|
|
112
|
-
_module_instance = _UnavailableConf(__name__, __doc__)
|
|
113
|
-
else:
|
|
114
|
-
_module_instance = get_conf_module(__name__, __doc__)
|
|
115
|
-
else:
|
|
116
|
-
_module_instance = get_conf_module(__name__, __doc__)
|
|
98
|
+
# Configuration module - self-contained without xwlazy dependency
|
|
99
|
+
class _ConfModule(types.ModuleType):
|
|
100
|
+
"""Self-contained configuration module without xwlazy dependency."""
|
|
101
|
+
def __getattr__(self, name: str):
|
|
102
|
+
# Return a simple configuration object
|
|
103
|
+
# This can be extended later if needed
|
|
104
|
+
raise AttributeError(f"module '{__name__}' has no attribute '{name}'")
|
|
105
|
+
|
|
106
|
+
_module_instance = _ConfModule(__name__, __doc__)
|
|
117
107
|
|
|
118
108
|
sys.modules[__name__] = _module_instance
|
|
119
109
|
|
exonware/xwsystem/__init__.py
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Company: eXonware.com
|
|
4
4
|
Author: Eng. Muhammad AlShehri
|
|
5
5
|
Email: connect@exonware.com
|
|
6
|
-
Version: 0.0.1.
|
|
6
|
+
Version: 0.0.1.411
|
|
7
7
|
Generation Date: October 10, 2025
|
|
8
8
|
|
|
9
9
|
XWSystem - Enterprise-grade Python framework with AI-powered performance optimization.
|
|
@@ -50,7 +50,6 @@ This module provides common utilities that can be used across different
|
|
|
50
50
|
components including threading, security, I/O, data structures, and design patterns.
|
|
51
51
|
"""
|
|
52
52
|
|
|
53
|
-
import importlib
|
|
54
53
|
import logging
|
|
55
54
|
from typing import TYPE_CHECKING
|
|
56
55
|
|
|
@@ -58,17 +57,6 @@ from typing import TYPE_CHECKING
|
|
|
58
57
|
if TYPE_CHECKING:
|
|
59
58
|
from typing import Any
|
|
60
59
|
|
|
61
|
-
# =============================================================================
|
|
62
|
-
# LAZY MODE INTEGRATION
|
|
63
|
-
# =============================================================================
|
|
64
|
-
# Minimal-intrusion lazy mode bootstrap (one line)
|
|
65
|
-
# Enables optimized lazy mode for xwsystem if xwlazy is installed
|
|
66
|
-
# Uses fastest mode from benchmarks: cached + full (1.482 ms)
|
|
67
|
-
try:
|
|
68
|
-
from .lazy_bootstrap import _bootstrap_lazy_mode # noqa: F401
|
|
69
|
-
except ImportError:
|
|
70
|
-
pass # xwlazy not installed - silently continue
|
|
71
|
-
|
|
72
60
|
# Logging utilities
|
|
73
61
|
from .config.logging_setup import get_logger, setup_logging
|
|
74
62
|
|
|
@@ -111,8 +99,8 @@ from .io.serialization import (
|
|
|
111
99
|
)
|
|
112
100
|
|
|
113
101
|
# HTTP utilities
|
|
114
|
-
from .
|
|
115
|
-
from .
|
|
102
|
+
from .http_client import HttpClient, AsyncHttpClient, HttpError, RetryConfig
|
|
103
|
+
from .http_client.advanced_client import (
|
|
116
104
|
AdvancedHttpClient, AdvancedHttpConfig, Http2Config,
|
|
117
105
|
StreamingConfig, MockTransport, MockResponse
|
|
118
106
|
)
|
|
@@ -124,6 +112,7 @@ from .runtime import EnvironmentManager, ReflectionUtils
|
|
|
124
112
|
from .plugins import PluginManager, PluginBase, PluginRegistry
|
|
125
113
|
|
|
126
114
|
# I/O utilities
|
|
115
|
+
from .io.facade import XWIO
|
|
127
116
|
from .io.common.atomic import (
|
|
128
117
|
AtomicFileWriter,
|
|
129
118
|
FileOperationError,
|
|
@@ -502,7 +491,7 @@ def list_available_formats():
|
|
|
502
491
|
List all available serialization formats.
|
|
503
492
|
|
|
504
493
|
Returns:
|
|
505
|
-
|
|
494
|
+
dict with format categories and their available formats
|
|
506
495
|
|
|
507
496
|
Example:
|
|
508
497
|
>>> formats = list_available_formats()
|
|
@@ -628,6 +617,7 @@ __all__ = [
|
|
|
628
617
|
"hash_password", "hash_password_async",
|
|
629
618
|
"verify_password", "verify_password_async",
|
|
630
619
|
# I/O
|
|
620
|
+
"XWIO",
|
|
631
621
|
"AtomicFileWriter",
|
|
632
622
|
"FileOperationError",
|
|
633
623
|
"safe_write_text",
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
#exonware/
|
|
1
|
+
#exonware/xwsystem/caching/base.py
|
|
2
2
|
"""
|
|
3
3
|
Company: eXonware.com
|
|
4
4
|
Author: Eng. Muhammad AlShehri
|
|
5
5
|
Email: connect@exonware.com
|
|
6
|
-
Version: 0.0.1.
|
|
6
|
+
Version: 0.0.1.411
|
|
7
7
|
Generation Date: September 04, 2025
|
|
8
8
|
|
|
9
9
|
Caching module base classes - abstract classes for caching functionality.
|
|
10
10
|
"""
|
|
11
11
|
|
|
12
12
|
from abc import ABC, abstractmethod
|
|
13
|
-
from typing import Any,
|
|
13
|
+
from typing import Any, Optional, Union, Hashable
|
|
14
14
|
from .defs import CachePolicy
|
|
15
15
|
|
|
16
16
|
|
|
@@ -27,9 +27,9 @@ class ACache(ABC):
|
|
|
27
27
|
"""
|
|
28
28
|
self.capacity = capacity
|
|
29
29
|
self.ttl = ttl
|
|
30
|
-
self._cache:
|
|
31
|
-
self._access_times:
|
|
32
|
-
self._creation_times:
|
|
30
|
+
self._cache: dict[str, Any] = {}
|
|
31
|
+
self._access_times: dict[str, float] = {}
|
|
32
|
+
self._creation_times: dict[str, float] = {}
|
|
33
33
|
|
|
34
34
|
@abstractmethod
|
|
35
35
|
def get(self, key: Any, default: Any = None) -> Optional[Any]:
|
|
@@ -90,7 +90,7 @@ class ACache(ABC):
|
|
|
90
90
|
pass
|
|
91
91
|
|
|
92
92
|
@abstractmethod
|
|
93
|
-
def keys(self) ->
|
|
93
|
+
def keys(self) -> list[Hashable]:
|
|
94
94
|
"""
|
|
95
95
|
Get list of all cache keys.
|
|
96
96
|
|
|
@@ -100,7 +100,7 @@ class ACache(ABC):
|
|
|
100
100
|
pass
|
|
101
101
|
|
|
102
102
|
@abstractmethod
|
|
103
|
-
def values(self) ->
|
|
103
|
+
def values(self) -> list[Any]:
|
|
104
104
|
"""
|
|
105
105
|
Get list of all cache values.
|
|
106
106
|
|
|
@@ -110,7 +110,7 @@ class ACache(ABC):
|
|
|
110
110
|
pass
|
|
111
111
|
|
|
112
112
|
@abstractmethod
|
|
113
|
-
def items(self) ->
|
|
113
|
+
def items(self) -> list[tuple[Hashable, Any]]:
|
|
114
114
|
"""
|
|
115
115
|
Get list of all key-value pairs.
|
|
116
116
|
|
|
@@ -120,7 +120,7 @@ class ACache(ABC):
|
|
|
120
120
|
pass
|
|
121
121
|
|
|
122
122
|
@abstractmethod
|
|
123
|
-
def get_stats(self) ->
|
|
123
|
+
def get_stats(self) -> dict[str, Any]:
|
|
124
124
|
"""
|
|
125
125
|
Get cache statistics.
|
|
126
126
|
|
|
@@ -151,7 +151,7 @@ class ACache(ABC):
|
|
|
151
151
|
"""
|
|
152
152
|
return self.size()
|
|
153
153
|
|
|
154
|
-
def get_many(self, keys:
|
|
154
|
+
def get_many(self, keys: list[Hashable]) -> dict[Hashable, Any]:
|
|
155
155
|
"""
|
|
156
156
|
Get multiple values in a single operation.
|
|
157
157
|
|
|
@@ -171,7 +171,7 @@ class ACache(ABC):
|
|
|
171
171
|
results[key] = value
|
|
172
172
|
return results
|
|
173
173
|
|
|
174
|
-
def put_many(self, items:
|
|
174
|
+
def put_many(self, items: dict[Hashable, Any]) -> int:
|
|
175
175
|
"""
|
|
176
176
|
Put multiple key-value pairs in a single operation.
|
|
177
177
|
|
|
@@ -194,7 +194,7 @@ class ACache(ABC):
|
|
|
194
194
|
pass
|
|
195
195
|
return count
|
|
196
196
|
|
|
197
|
-
def delete_many(self, keys:
|
|
197
|
+
def delete_many(self, keys: list[Hashable]) -> int:
|
|
198
198
|
"""
|
|
199
199
|
Delete multiple keys in a single operation.
|
|
200
200
|
|
|
@@ -233,7 +233,7 @@ class ACacheManager(ABC):
|
|
|
233
233
|
pass
|
|
234
234
|
|
|
235
235
|
@abstractmethod
|
|
236
|
-
def list_caches(self) ->
|
|
236
|
+
def list_caches(self) -> list[str]:
|
|
237
237
|
"""List all cache names."""
|
|
238
238
|
pass
|
|
239
239
|
|
|
@@ -247,7 +247,7 @@ class ADistributedCache(ABC):
|
|
|
247
247
|
"""Abstract base class for distributed cache implementations."""
|
|
248
248
|
|
|
249
249
|
@abstractmethod
|
|
250
|
-
def connect(self, nodes:
|
|
250
|
+
def connect(self, nodes: list[str]) -> None:
|
|
251
251
|
"""Connect to distributed cache nodes."""
|
|
252
252
|
pass
|
|
253
253
|
|
|
@@ -262,7 +262,7 @@ class ADistributedCache(ABC):
|
|
|
262
262
|
pass
|
|
263
263
|
|
|
264
264
|
@abstractmethod
|
|
265
|
-
def get_node_info(self) ->
|
|
265
|
+
def get_node_info(self) -> dict[str, Any]:
|
|
266
266
|
"""Get distributed cache node information."""
|
|
267
267
|
pass
|
|
268
268
|
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Company: eXonware.com
|
|
4
4
|
Author: Eng. Muhammad AlShehri
|
|
5
5
|
Email: connect@exonware.com
|
|
6
|
-
Version: 0.0.1.
|
|
6
|
+
Version: 0.0.1.411
|
|
7
7
|
Generation Date: 01-Nov-2025
|
|
8
8
|
|
|
9
9
|
Bloom filter-enhanced cache for faster negative lookups.
|
|
@@ -11,11 +11,11 @@ Performance Priority #4 - Probabilistic data structure for efficiency.
|
|
|
11
11
|
"""
|
|
12
12
|
|
|
13
13
|
import hashlib
|
|
14
|
-
from typing import Any,
|
|
14
|
+
from typing import Any, Optional, Hashable
|
|
15
15
|
from .lru_cache import LRUCache
|
|
16
16
|
from ..config.logging_setup import get_logger
|
|
17
17
|
|
|
18
|
-
logger = get_logger("
|
|
18
|
+
logger = get_logger("xwsystem.caching.bloom_cache")
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
class SimpleBloomFilter:
|
|
@@ -38,7 +38,7 @@ class SimpleBloomFilter:
|
|
|
38
38
|
self.bit_array = [False] * size
|
|
39
39
|
self.items_added = 0
|
|
40
40
|
|
|
41
|
-
def _hashes(self, item: Any) ->
|
|
41
|
+
def _hashes(self, item: Any) -> list[int]:
|
|
42
42
|
"""Generate multiple hash values for item."""
|
|
43
43
|
hashes = []
|
|
44
44
|
item_bytes = str(item).encode('utf-8')
|
|
@@ -191,7 +191,7 @@ class BloomFilterCache(LRUCache):
|
|
|
191
191
|
self._bloom.add(key)
|
|
192
192
|
logger.info("Bloom filter rebuilt")
|
|
193
193
|
|
|
194
|
-
def get_stats(self) ->
|
|
194
|
+
def get_stats(self) -> dict[str, Any]:
|
|
195
195
|
"""Get statistics including Bloom filter metrics."""
|
|
196
196
|
stats = super().get_stats()
|
|
197
197
|
stats['bloom_size'] = self._bloom.size
|
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
Company: eXonware.com
|
|
3
3
|
Author: Eng. Muhammad AlShehri
|
|
4
4
|
Email: connect@exonware.com
|
|
5
|
-
Version: 0.0.1.
|
|
5
|
+
Version: 0.0.1.411
|
|
6
6
|
Generation Date: September 04, 2025
|
|
7
7
|
|
|
8
8
|
Cache Manager implementation - Placeholder.
|
|
9
9
|
"""
|
|
10
10
|
|
|
11
11
|
from dataclasses import dataclass
|
|
12
|
-
from typing import
|
|
12
|
+
from typing import Any
|
|
13
13
|
|
|
14
14
|
@dataclass
|
|
15
15
|
class CacheConfig:
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Company: eXonware.com
|
|
4
4
|
Author: Eng. Muhammad AlShehri
|
|
5
5
|
Email: connect@exonware.com
|
|
6
|
-
Version: 0.0.1.
|
|
6
|
+
Version: 0.0.1.411
|
|
7
7
|
Generation Date: 01-Nov-2025
|
|
8
8
|
|
|
9
9
|
Conditional eviction policies for caching.
|
|
@@ -11,11 +11,11 @@ Extensibility Priority #5 - Customizable eviction behavior.
|
|
|
11
11
|
"""
|
|
12
12
|
|
|
13
13
|
import time
|
|
14
|
-
from typing import Any, Callable,
|
|
14
|
+
from typing import Any, Callable, Optional, Hashable
|
|
15
15
|
from .lru_cache import LRUCache, CacheNode
|
|
16
16
|
from ..config.logging_setup import get_logger
|
|
17
17
|
|
|
18
|
-
logger = get_logger("
|
|
18
|
+
logger = get_logger("xwsystem.caching.conditional")
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
class ConditionalEvictionCache(LRUCache):
|
|
@@ -136,7 +136,7 @@ class ConditionalEvictionCache(LRUCache):
|
|
|
136
136
|
self.eviction_policy = policy
|
|
137
137
|
logger.info("Eviction policy updated")
|
|
138
138
|
|
|
139
|
-
def get_stats(self) ->
|
|
139
|
+
def get_stats(self) -> dict[str, Any]:
|
|
140
140
|
"""Get statistics including eviction rejections."""
|
|
141
141
|
stats = super().get_stats()
|
|
142
142
|
stats['eviction_rejections'] = self._eviction_rejections
|
|
@@ -3,14 +3,14 @@
|
|
|
3
3
|
Company: eXonware.com
|
|
4
4
|
Author: Eng. Muhammad AlShehri
|
|
5
5
|
Email: connect@exonware.com
|
|
6
|
-
Version: 0.0.1.
|
|
6
|
+
Version: 0.0.1.411
|
|
7
7
|
Generation Date: September 04, 2025
|
|
8
8
|
|
|
9
9
|
Caching protocol interfaces for XWSystem.
|
|
10
10
|
"""
|
|
11
11
|
|
|
12
12
|
from abc import ABC, abstractmethod
|
|
13
|
-
from typing import Any,
|
|
13
|
+
from typing import Any, Optional, Union, Iterator, Callable, Protocol
|
|
14
14
|
from typing_extensions import runtime_checkable
|
|
15
15
|
import time
|
|
16
16
|
|
|
@@ -107,7 +107,7 @@ class ICacheable(ABC):
|
|
|
107
107
|
pass
|
|
108
108
|
|
|
109
109
|
@abstractmethod
|
|
110
|
-
def get_cache_info(self) ->
|
|
110
|
+
def get_cache_info(self) -> dict[str, Any]:
|
|
111
111
|
"""
|
|
112
112
|
Get cache information.
|
|
113
113
|
|
|
@@ -170,7 +170,7 @@ class ICacheManager(ABC):
|
|
|
170
170
|
pass
|
|
171
171
|
|
|
172
172
|
@abstractmethod
|
|
173
|
-
def list_caches(self) ->
|
|
173
|
+
def list_caches(self) -> list[str]:
|
|
174
174
|
"""
|
|
175
175
|
List all cache names.
|
|
176
176
|
|
|
@@ -187,7 +187,7 @@ class ICacheManager(ABC):
|
|
|
187
187
|
pass
|
|
188
188
|
|
|
189
189
|
@abstractmethod
|
|
190
|
-
def get_cache_stats(self) ->
|
|
190
|
+
def get_cache_stats(self) -> dict[str, dict[str, Any]]:
|
|
191
191
|
"""
|
|
192
192
|
Get statistics for all caches.
|
|
193
193
|
|
|
@@ -320,7 +320,7 @@ class ICacheStorage(ABC):
|
|
|
320
320
|
pass
|
|
321
321
|
|
|
322
322
|
@abstractmethod
|
|
323
|
-
def items(self) -> Iterator[
|
|
323
|
+
def items(self) -> Iterator[tuple[str, Any]]:
|
|
324
324
|
"""
|
|
325
325
|
Get iterator over cache items.
|
|
326
326
|
|
|
@@ -356,7 +356,7 @@ class ICacheEviction(ABC):
|
|
|
356
356
|
pass
|
|
357
357
|
|
|
358
358
|
@abstractmethod
|
|
359
|
-
def select_eviction_candidate(self, items:
|
|
359
|
+
def select_eviction_candidate(self, items: list[tuple[str, Any, float]]) -> str:
|
|
360
360
|
"""
|
|
361
361
|
Select item to evict.
|
|
362
362
|
|
|
@@ -400,7 +400,7 @@ class ICacheEviction(ABC):
|
|
|
400
400
|
pass
|
|
401
401
|
|
|
402
402
|
@abstractmethod
|
|
403
|
-
def get_eviction_stats(self) ->
|
|
403
|
+
def get_eviction_stats(self) -> dict[str, Any]:
|
|
404
404
|
"""
|
|
405
405
|
Get eviction statistics.
|
|
406
406
|
|
|
@@ -494,7 +494,7 @@ class ICacheMonitor(ABC):
|
|
|
494
494
|
pass
|
|
495
495
|
|
|
496
496
|
@abstractmethod
|
|
497
|
-
def get_stats(self) ->
|
|
497
|
+
def get_stats(self) -> dict[str, Any]:
|
|
498
498
|
"""
|
|
499
499
|
Get cache statistics.
|
|
500
500
|
|
|
@@ -533,7 +533,7 @@ class IDistributedCache(ABC):
|
|
|
533
533
|
pass
|
|
534
534
|
|
|
535
535
|
@abstractmethod
|
|
536
|
-
def get_cluster_nodes(self) ->
|
|
536
|
+
def get_cluster_nodes(self) -> list[str]:
|
|
537
537
|
"""
|
|
538
538
|
Get list of cluster nodes.
|
|
539
539
|
|
|
@@ -543,7 +543,7 @@ class IDistributedCache(ABC):
|
|
|
543
543
|
pass
|
|
544
544
|
|
|
545
545
|
@abstractmethod
|
|
546
|
-
def replicate(self, key: str, value: Any, nodes:
|
|
546
|
+
def replicate(self, key: str, value: Any, nodes: list[str]) -> bool:
|
|
547
547
|
"""
|
|
548
548
|
Replicate cache entry to nodes.
|
|
549
549
|
|
|
@@ -558,7 +558,7 @@ class IDistributedCache(ABC):
|
|
|
558
558
|
pass
|
|
559
559
|
|
|
560
560
|
@abstractmethod
|
|
561
|
-
def invalidate(self, key: str, nodes:
|
|
561
|
+
def invalidate(self, key: str, nodes: list[str]) -> bool:
|
|
562
562
|
"""
|
|
563
563
|
Invalidate cache entry on nodes.
|
|
564
564
|
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
Company: eXonware.com
|
|
5
5
|
Author: Eng. Muhammad AlShehri
|
|
6
6
|
Email: connect@exonware.com
|
|
7
|
-
Version: 0.0.1.
|
|
7
|
+
Version: 0.0.1.411
|
|
8
8
|
Generation Date: 01-Nov-2025
|
|
9
9
|
|
|
10
10
|
Advanced cache decorators with hooks and customization.
|
|
@@ -18,7 +18,7 @@ from .lru_cache import LRUCache, AsyncLRUCache
|
|
|
18
18
|
from .utils import default_key_builder
|
|
19
19
|
from ..config.logging_setup import get_logger
|
|
20
20
|
|
|
21
|
-
logger = get_logger("
|
|
21
|
+
logger = get_logger("xwsystem.caching.decorators")
|
|
22
22
|
|
|
23
23
|
|
|
24
24
|
def xwcached(
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Company: eXonware.com
|
|
4
4
|
Author: Eng. Muhammad AlShehri
|
|
5
5
|
Email: connect@exonware.com
|
|
6
|
-
Version: 0.0.1.
|
|
6
|
+
Version: 0.0.1.411
|
|
7
7
|
Generation Date: October 26, 2025
|
|
8
8
|
|
|
9
9
|
Disk cache implementation with pickle-based persistence.
|
|
@@ -15,7 +15,7 @@ import hashlib
|
|
|
15
15
|
import threading
|
|
16
16
|
import time
|
|
17
17
|
from pathlib import Path
|
|
18
|
-
from typing import Any, Optional
|
|
18
|
+
from typing import Any, Optional
|
|
19
19
|
from .contracts import ICache
|
|
20
20
|
from .errors import CacheError
|
|
21
21
|
from ..config.logging_setup import get_logger
|
|
@@ -72,7 +72,7 @@ class DiskCache(ICache):
|
|
|
72
72
|
|
|
73
73
|
# Metadata file for tracking cache entries
|
|
74
74
|
self.metadata_file = self.cache_dir / "metadata.pkl"
|
|
75
|
-
self._metadata:
|
|
75
|
+
self._metadata: dict[str, dict[str, Any]] = {}
|
|
76
76
|
self._load_metadata()
|
|
77
77
|
|
|
78
78
|
# Statistics
|
|
@@ -308,7 +308,7 @@ class DiskCache(ICache):
|
|
|
308
308
|
with self._lock:
|
|
309
309
|
return len(self._metadata)
|
|
310
310
|
|
|
311
|
-
def get_stats(self) ->
|
|
311
|
+
def get_stats(self) -> dict[str, Any]:
|
|
312
312
|
"""Get cache statistics."""
|
|
313
313
|
with self._lock:
|
|
314
314
|
total_requests = self._stats['hits'] + self._stats['misses']
|
|
@@ -4,18 +4,18 @@
|
|
|
4
4
|
Company: eXonware.com
|
|
5
5
|
Author: Eng. Muhammad AlShehri
|
|
6
6
|
Email: connect@exonware.com
|
|
7
|
-
Version: 0.0.1.
|
|
7
|
+
Version: 0.0.1.411
|
|
8
8
|
Generation Date: 01-Nov-2025
|
|
9
9
|
|
|
10
10
|
Event system for caching module.
|
|
11
11
|
Extensibility Priority #5 - Event-driven architecture for custom behaviors.
|
|
12
12
|
"""
|
|
13
13
|
|
|
14
|
-
from typing import Callable,
|
|
14
|
+
from typing import Callable, Any, Optional
|
|
15
15
|
from enum import Enum
|
|
16
16
|
from ..config.logging_setup import get_logger
|
|
17
17
|
|
|
18
|
-
logger = get_logger("
|
|
18
|
+
logger = get_logger("xwsystem.caching.events")
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
class CacheEvent(Enum):
|
|
@@ -49,10 +49,10 @@ class CacheEventEmitter:
|
|
|
49
49
|
|
|
50
50
|
def __init__(self):
|
|
51
51
|
"""Initialize event emitter."""
|
|
52
|
-
self._hooks:
|
|
52
|
+
self._hooks: dict[CacheEvent, list[Callable]] = {
|
|
53
53
|
event: [] for event in CacheEvent
|
|
54
54
|
}
|
|
55
|
-
self._event_stats:
|
|
55
|
+
self._event_stats: dict[CacheEvent, int] = {
|
|
56
56
|
event: 0 for event in CacheEvent
|
|
57
57
|
}
|
|
58
58
|
|
|
@@ -124,7 +124,7 @@ class CacheEventEmitter:
|
|
|
124
124
|
logger.error(f"Event callback failed for {event.value}: {e}")
|
|
125
125
|
self._emit(CacheEvent.ERROR, error=e, event=event, **kwargs)
|
|
126
126
|
|
|
127
|
-
def get_event_stats(self) ->
|
|
127
|
+
def get_event_stats(self) -> dict[str, int]:
|
|
128
128
|
"""
|
|
129
129
|
Get event emission statistics.
|
|
130
130
|
|
|
@@ -149,7 +149,7 @@ class EventLogger:
|
|
|
149
149
|
log_level: Logging level for events
|
|
150
150
|
"""
|
|
151
151
|
self.log_level = log_level
|
|
152
|
-
self.events_log:
|
|
152
|
+
self.events_log: list[dict[str, Any]] = []
|
|
153
153
|
|
|
154
154
|
def __call__(self, event: CacheEvent, **kwargs):
|
|
155
155
|
"""Log event."""
|
|
@@ -180,7 +180,7 @@ class EventLogger:
|
|
|
180
180
|
elif event == CacheEvent.ERROR:
|
|
181
181
|
logger.error(f"[EVENT] Cache ERROR: {kwargs.get('error', 'Unknown')}")
|
|
182
182
|
|
|
183
|
-
def get_events(self, event_type: Optional[CacheEvent] = None) ->
|
|
183
|
+
def get_events(self, event_type: Optional[CacheEvent] = None) -> list[dict[str, Any]]:
|
|
184
184
|
"""Get logged events, optionally filtered by type."""
|
|
185
185
|
if event_type:
|
|
186
186
|
return [e for e in self.events_log if e['event'] == event_type.value]
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
Company: eXonware.com
|
|
5
5
|
Author: Eng. Muhammad AlShehri
|
|
6
6
|
Email: connect@exonware.com
|
|
7
|
-
Version: 0.0.1.
|
|
7
|
+
Version: 0.0.1.411
|
|
8
8
|
Generation Date: 01-Nov-2025
|
|
9
9
|
|
|
10
10
|
Pluggable eviction strategies for caching module.
|
|
@@ -12,7 +12,7 @@ Extensibility Priority #5 - Strategy pattern for custom eviction policies.
|
|
|
12
12
|
"""
|
|
13
13
|
|
|
14
14
|
from abc import ABC, abstractmethod
|
|
15
|
-
from typing import Any,
|
|
15
|
+
from typing import Any, Optional, Hashable
|
|
16
16
|
import random
|
|
17
17
|
import time
|
|
18
18
|
|
|
@@ -25,7 +25,7 @@ class AEvictionStrategy(ABC):
|
|
|
25
25
|
"""
|
|
26
26
|
|
|
27
27
|
@abstractmethod
|
|
28
|
-
def select_victim(self, cache_items:
|
|
28
|
+
def select_victim(self, cache_items: list[tuple[Hashable, Any, dict]]) -> Optional[Hashable]:
|
|
29
29
|
"""
|
|
30
30
|
Select item to evict from cache.
|
|
31
31
|
|
|
@@ -80,7 +80,7 @@ class AEvictionStrategy(ABC):
|
|
|
80
80
|
class LRUEvictionStrategy(AEvictionStrategy):
|
|
81
81
|
"""Least Recently Used eviction strategy."""
|
|
82
82
|
|
|
83
|
-
def select_victim(self, cache_items:
|
|
83
|
+
def select_victim(self, cache_items: list[tuple[Hashable, Any, dict]]) -> Optional[Hashable]:
|
|
84
84
|
"""Select least recently used item."""
|
|
85
85
|
if not cache_items:
|
|
86
86
|
return None
|
|
@@ -113,7 +113,7 @@ class LFUEvictionStrategy(AEvictionStrategy):
|
|
|
113
113
|
"""Initialize LFU strategy."""
|
|
114
114
|
self._access_counts: dict = {}
|
|
115
115
|
|
|
116
|
-
def select_victim(self, cache_items:
|
|
116
|
+
def select_victim(self, cache_items: list[tuple[Hashable, Any, dict]]) -> Optional[Hashable]:
|
|
117
117
|
"""Select least frequently used item."""
|
|
118
118
|
if not cache_items:
|
|
119
119
|
return None
|
|
@@ -144,7 +144,7 @@ class LFUEvictionStrategy(AEvictionStrategy):
|
|
|
144
144
|
class FIFOEvictionStrategy(AEvictionStrategy):
|
|
145
145
|
"""First In, First Out eviction strategy."""
|
|
146
146
|
|
|
147
|
-
def select_victim(self, cache_items:
|
|
147
|
+
def select_victim(self, cache_items: list[tuple[Hashable, Any, dict]]) -> Optional[Hashable]:
|
|
148
148
|
"""Select oldest inserted item."""
|
|
149
149
|
if not cache_items:
|
|
150
150
|
return None
|
|
@@ -173,7 +173,7 @@ class FIFOEvictionStrategy(AEvictionStrategy):
|
|
|
173
173
|
class RandomEvictionStrategy(AEvictionStrategy):
|
|
174
174
|
"""Random eviction strategy."""
|
|
175
175
|
|
|
176
|
-
def select_victim(self, cache_items:
|
|
176
|
+
def select_victim(self, cache_items: list[tuple[Hashable, Any, dict]]) -> Optional[Hashable]:
|
|
177
177
|
"""Select random item to evict."""
|
|
178
178
|
if not cache_items:
|
|
179
179
|
return None
|
|
@@ -201,7 +201,7 @@ class RandomEvictionStrategy(AEvictionStrategy):
|
|
|
201
201
|
class SizeBasedEvictionStrategy(AEvictionStrategy):
|
|
202
202
|
"""Evict largest items first to free maximum memory."""
|
|
203
203
|
|
|
204
|
-
def select_victim(self, cache_items:
|
|
204
|
+
def select_victim(self, cache_items: list[tuple[Hashable, Any, dict]]) -> Optional[Hashable]:
|
|
205
205
|
"""Select largest item to evict."""
|
|
206
206
|
if not cache_items:
|
|
207
207
|
return None
|
|
@@ -231,7 +231,7 @@ class SizeBasedEvictionStrategy(AEvictionStrategy):
|
|
|
231
231
|
class TTLEvictionStrategy(AEvictionStrategy):
|
|
232
232
|
"""Evict items closest to expiration first."""
|
|
233
233
|
|
|
234
|
-
def select_victim(self, cache_items:
|
|
234
|
+
def select_victim(self, cache_items: list[tuple[Hashable, Any, dict]]) -> Optional[Hashable]:
|
|
235
235
|
"""Select item closest to expiration."""
|
|
236
236
|
if not cache_items:
|
|
237
237
|
return None
|