exonware-xwlazy 0.1.0.23__py3-none-any.whl → 1.0.1.2__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.
Files changed (96) hide show
  1. exonware/__init__.py +85 -34
  2. exonware/xwlazy/version.py +5 -5
  3. exonware/xwlazy.py +2546 -0
  4. exonware/xwlazy_external_libs.toml +716 -0
  5. {exonware_xwlazy-0.1.0.23.dist-info → exonware_xwlazy-1.0.1.2.dist-info}/METADATA +5 -1
  6. exonware_xwlazy-1.0.1.2.dist-info/RECORD +8 -0
  7. exonware/xwlazy/__init__.py +0 -379
  8. exonware/xwlazy/common/__init__.py +0 -55
  9. exonware/xwlazy/common/base.py +0 -65
  10. exonware/xwlazy/common/cache.py +0 -504
  11. exonware/xwlazy/common/logger.py +0 -257
  12. exonware/xwlazy/common/services/__init__.py +0 -72
  13. exonware/xwlazy/common/services/dependency_mapper.py +0 -250
  14. exonware/xwlazy/common/services/install_async_utils.py +0 -170
  15. exonware/xwlazy/common/services/install_cache_utils.py +0 -245
  16. exonware/xwlazy/common/services/keyword_detection.py +0 -283
  17. exonware/xwlazy/common/services/spec_cache.py +0 -165
  18. exonware/xwlazy/common/services/state_manager.py +0 -84
  19. exonware/xwlazy/common/strategies/__init__.py +0 -28
  20. exonware/xwlazy/common/strategies/caching_dict.py +0 -44
  21. exonware/xwlazy/common/strategies/caching_installation.py +0 -88
  22. exonware/xwlazy/common/strategies/caching_lfu.py +0 -66
  23. exonware/xwlazy/common/strategies/caching_lru.py +0 -63
  24. exonware/xwlazy/common/strategies/caching_multitier.py +0 -59
  25. exonware/xwlazy/common/strategies/caching_ttl.py +0 -59
  26. exonware/xwlazy/common/utils.py +0 -142
  27. exonware/xwlazy/config.py +0 -193
  28. exonware/xwlazy/contracts.py +0 -1533
  29. exonware/xwlazy/defs.py +0 -378
  30. exonware/xwlazy/errors.py +0 -276
  31. exonware/xwlazy/facade.py +0 -1137
  32. exonware/xwlazy/host/__init__.py +0 -8
  33. exonware/xwlazy/host/conf.py +0 -16
  34. exonware/xwlazy/module/__init__.py +0 -18
  35. exonware/xwlazy/module/base.py +0 -622
  36. exonware/xwlazy/module/data.py +0 -17
  37. exonware/xwlazy/module/facade.py +0 -246
  38. exonware/xwlazy/module/importer_engine.py +0 -2964
  39. exonware/xwlazy/module/partial_module_detector.py +0 -275
  40. exonware/xwlazy/module/strategies/__init__.py +0 -22
  41. exonware/xwlazy/module/strategies/module_helper_lazy.py +0 -93
  42. exonware/xwlazy/module/strategies/module_helper_simple.py +0 -65
  43. exonware/xwlazy/module/strategies/module_manager_advanced.py +0 -111
  44. exonware/xwlazy/module/strategies/module_manager_simple.py +0 -95
  45. exonware/xwlazy/package/__init__.py +0 -18
  46. exonware/xwlazy/package/base.py +0 -863
  47. exonware/xwlazy/package/conf.py +0 -324
  48. exonware/xwlazy/package/data.py +0 -17
  49. exonware/xwlazy/package/facade.py +0 -480
  50. exonware/xwlazy/package/services/__init__.py +0 -84
  51. exonware/xwlazy/package/services/async_install_handle.py +0 -87
  52. exonware/xwlazy/package/services/config_manager.py +0 -249
  53. exonware/xwlazy/package/services/discovery.py +0 -435
  54. exonware/xwlazy/package/services/host_packages.py +0 -180
  55. exonware/xwlazy/package/services/install_async.py +0 -291
  56. exonware/xwlazy/package/services/install_cache.py +0 -145
  57. exonware/xwlazy/package/services/install_interactive.py +0 -59
  58. exonware/xwlazy/package/services/install_policy.py +0 -156
  59. exonware/xwlazy/package/services/install_registry.py +0 -54
  60. exonware/xwlazy/package/services/install_result.py +0 -17
  61. exonware/xwlazy/package/services/install_sbom.py +0 -153
  62. exonware/xwlazy/package/services/install_utils.py +0 -79
  63. exonware/xwlazy/package/services/installer_engine.py +0 -406
  64. exonware/xwlazy/package/services/lazy_installer.py +0 -803
  65. exonware/xwlazy/package/services/manifest.py +0 -503
  66. exonware/xwlazy/package/services/strategy_registry.py +0 -324
  67. exonware/xwlazy/package/strategies/__init__.py +0 -57
  68. exonware/xwlazy/package/strategies/package_discovery_file.py +0 -129
  69. exonware/xwlazy/package/strategies/package_discovery_hybrid.py +0 -84
  70. exonware/xwlazy/package/strategies/package_discovery_manifest.py +0 -101
  71. exonware/xwlazy/package/strategies/package_execution_async.py +0 -113
  72. exonware/xwlazy/package/strategies/package_execution_cached.py +0 -90
  73. exonware/xwlazy/package/strategies/package_execution_pip.py +0 -99
  74. exonware/xwlazy/package/strategies/package_execution_wheel.py +0 -106
  75. exonware/xwlazy/package/strategies/package_mapping_discovery_first.py +0 -100
  76. exonware/xwlazy/package/strategies/package_mapping_hybrid.py +0 -105
  77. exonware/xwlazy/package/strategies/package_mapping_manifest_first.py +0 -100
  78. exonware/xwlazy/package/strategies/package_policy_allow_list.py +0 -57
  79. exonware/xwlazy/package/strategies/package_policy_deny_list.py +0 -57
  80. exonware/xwlazy/package/strategies/package_policy_permissive.py +0 -46
  81. exonware/xwlazy/package/strategies/package_timing_clean.py +0 -67
  82. exonware/xwlazy/package/strategies/package_timing_full.py +0 -66
  83. exonware/xwlazy/package/strategies/package_timing_smart.py +0 -68
  84. exonware/xwlazy/package/strategies/package_timing_temporary.py +0 -66
  85. exonware/xwlazy/runtime/__init__.py +0 -18
  86. exonware/xwlazy/runtime/adaptive_learner.py +0 -129
  87. exonware/xwlazy/runtime/base.py +0 -274
  88. exonware/xwlazy/runtime/facade.py +0 -94
  89. exonware/xwlazy/runtime/intelligent_selector.py +0 -170
  90. exonware/xwlazy/runtime/metrics.py +0 -60
  91. exonware/xwlazy/runtime/performance.py +0 -37
  92. exonware_xwlazy-0.1.0.23.dist-info/RECORD +0 -93
  93. xwlazy/__init__.py +0 -14
  94. xwlazy/lazy.py +0 -30
  95. {exonware_xwlazy-0.1.0.23.dist-info → exonware_xwlazy-1.0.1.2.dist-info}/WHEEL +0 -0
  96. {exonware_xwlazy-0.1.0.23.dist-info → exonware_xwlazy-1.0.1.2.dist-info}/licenses/LICENSE +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: exonware-xwlazy
3
- Version: 0.1.0.23
3
+ Version: 1.0.1.2
4
4
  Summary: Marker package that enables lazy install features across the eXonware suite.
5
5
  Project-URL: Homepage, https://exonware.com
6
6
  Project-URL: Repository, https://github.com/exonware/xwlazy
@@ -174,6 +174,10 @@ After `pip install -e .`, xwlazy automatically enables lazy loading for your pac
174
174
  ## 📖 Documentation
175
175
 
176
176
  - **[Architecture Reference](docs/REF_ARCH.md)** - System design, patterns, and structure
177
+ - **[Integration Guide](docs/INTEGRATION_GUIDE.md)** - Integration with xw libraries
178
+ - **[Best Practices](docs/BEST_PRACTICES.md)** - Usage guidelines and recommendations
179
+ - **[Troubleshooting Guide](docs/TROUBLESHOOTING.md)** - Common issues and solutions
180
+ - **[Production Deployment](docs/PRODUCTION_DEPLOYMENT.md)** - Production deployment guide
177
181
  - **[Keyword Detection Guide](docs/KEYWORD_DETECTION.md)** - Zero-code integration
178
182
  - **[Competition Benchmarks](benchmarks/competition_tests/)** - Performance comparisons
179
183
  - **[Performance Analysis](benchmarks/competition_tests/PERFORMANCE_ANALYSIS.md)** - Optimization recommendations
@@ -0,0 +1,8 @@
1
+ exonware/__init__.py,sha256=pJ73geou9GfYyPqjK4AzPGIrVT3zU_Gvr2vt2ndkUhM,3774
2
+ exonware/xwlazy.py,sha256=5iAWriwqzmCqv68DLmw2fwm4whz6FLSNDn8hHk6TPBU,113036
3
+ exonware/xwlazy_external_libs.toml,sha256=-btpWbrLeXC-0ojFD8lJl_kNT5V_ZYbk5ZqSAUrsdjs,17965
4
+ exonware/xwlazy/version.py,sha256=1FTi6sQR_qQoHLHVMX6Mz8xbwdwpQbZwaSuYUFNvV3w,2349
5
+ exonware_xwlazy-1.0.1.2.dist-info/METADATA,sha256=GPeqvBdqeban3zpr3MiOjw_Rg0kgQmClicx9vdikopo,17004
6
+ exonware_xwlazy-1.0.1.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
7
+ exonware_xwlazy-1.0.1.2.dist-info/licenses/LICENSE,sha256=w42ohoEUfhyT0NgiivAL4fWg2AMRLGnfXPMAR4EO-MU,1094
8
+ exonware_xwlazy-1.0.1.2.dist-info/RECORD,,
@@ -1,379 +0,0 @@
1
- """
2
- #exonware/xwlazy/src/exonware/xwlazy/__init__.py
3
-
4
- xwlazy: Lazy loading and on-demand package installation for Python.
5
-
6
- The xwlazy library provides automatic dependency installation and lazy loading
7
- capabilities, allowing packages to declare optional dependencies that are
8
- installed only when needed.
9
-
10
- Company: eXonware.com
11
- Author: Eng. Muhammad AlShehri
12
- Email: connect@exonware.com
13
- Generation Date: 10-Oct-2025
14
-
15
- Main Features:
16
- - Automatic dependency discovery from pyproject.toml and requirements.txt
17
- - On-demand package installation via import hooks
18
- - Two-stage lazy loading for optimal performance
19
- - Per-package lazy mode configuration
20
- - Security policies and allow/deny lists
21
- - SBOM generation and lockfile management
22
-
23
- Example:
24
- >>> from exonware.xwlazy import enable_lazy_mode, xwimport
25
- >>>
26
- >>> # Enable lazy mode for your package
27
- >>> enable_lazy_mode(package_name="my_package", lazy_install_mode="smart")
28
- >>>
29
- >>> # Import with automatic installation
30
- >>> pandas = xwimport("pandas") # Installs pandas if not available
31
- """
32
-
33
- # =============================================================================
34
- # VERSION
35
- # =============================================================================
36
-
37
- from .version import (
38
- __version__,
39
- VERSION_MAJOR,
40
- VERSION_MINOR,
41
- VERSION_PATCH,
42
- VERSION_BUILD,
43
- VERSION_SUFFIX,
44
- VERSION_STRING,
45
- get_version,
46
- get_version_info,
47
- get_version_dict,
48
- is_dev_version,
49
- is_release_version,
50
- )
51
-
52
- # =============================================================================
53
- # IMPORTS - Standard Python Imports (No Defensive Code!)
54
- # =============================================================================
55
-
56
- # Import from facade - provides unified public API
57
- from .facade import (
58
- # Facade functions
59
- enable_lazy_mode,
60
- disable_lazy_mode,
61
- is_lazy_mode_enabled,
62
- get_lazy_mode_stats,
63
- configure_lazy_mode,
64
- preload_modules,
65
- optimize_lazy_mode,
66
- # One-line activation API
67
- auto_enable_lazy,
68
- # Lazy-loader compatible API
69
- attach,
70
- # Public API functions
71
- enable_lazy_install,
72
- disable_lazy_install,
73
- is_lazy_install_enabled,
74
- set_lazy_install_mode,
75
- get_lazy_install_mode,
76
- install_missing_package,
77
- install_and_import,
78
- get_lazy_install_stats,
79
- get_all_lazy_install_stats,
80
- lazy_import_with_install,
81
- xwimport,
82
- # Hook functions
83
- install_import_hook,
84
- uninstall_import_hook,
85
- is_import_hook_installed,
86
- # Lazy loading functions
87
- enable_lazy_imports,
88
- disable_lazy_imports,
89
- is_lazy_import_enabled,
90
- lazy_import,
91
- register_lazy_module,
92
- preload_module,
93
- get_lazy_module,
94
- get_loading_stats,
95
- preload_frequently_used,
96
- get_lazy_import_stats,
97
- # Configuration
98
- config_package_lazy_install_enabled,
99
- config_module_lazy_load_enabled,
100
- sync_manifest_configuration,
101
- refresh_lazy_manifests,
102
- # Security & Policy
103
- set_package_allow_list,
104
- set_package_deny_list,
105
- add_to_package_allow_list,
106
- add_to_package_deny_list,
107
- set_package_index_url,
108
- set_package_extra_index_urls,
109
- add_package_trusted_host,
110
- set_package_lockfile,
111
- generate_package_sbom,
112
- check_externally_managed_environment,
113
- register_lazy_module_prefix,
114
- register_lazy_module_methods,
115
- # Keyword-based detection
116
- enable_keyword_detection,
117
- is_keyword_detection_enabled,
118
- get_keyword_detection_keyword,
119
- check_package_keywords,
120
- # Discovery functions
121
- get_lazy_discovery,
122
- discover_dependencies,
123
- export_dependency_mappings,
124
- )
125
-
126
- # Import contracts and base for advanced usage
127
- from .defs import PRESET_MODES, get_preset_mode
128
- from .defs import (
129
- LazyLoadMode,
130
- LazyInstallMode,
131
- PathType,
132
- DependencyInfo,
133
- LazyModeConfig,
134
- )
135
- from .contracts import (
136
- IPackageHelper,
137
- IModuleHelper,
138
- IRuntime,
139
- )
140
-
141
- # Import errors
142
- from .errors import (
143
- LazySystemError,
144
- LazyInstallError,
145
- LazyDiscoveryError,
146
- LazyHookError,
147
- LazySecurityError,
148
- ExternallyManagedError,
149
- DeferredImportError,
150
- )
151
-
152
- # Import config
153
- from .config import LazyConfig, DEFAULT_LAZY_CONFIG
154
-
155
- # Import abstract base classes directly from submodules
156
- from .package.base import APackageHelper
157
- from .module.base import AModuleHelper
158
- from .runtime.base import ARuntimeHelper
159
-
160
- # Import concrete implementations (lazy to prevent circular imports)
161
- from typing import Any
162
-
163
- def __getattr__(name: str) -> Any:
164
- """Lazy import for concrete facades to prevent circular dependencies."""
165
- if name == "XWPackageHelper":
166
- from .package import XWPackageHelper
167
- return XWPackageHelper
168
- elif name == "XWModuleHelper":
169
- from .module import XWModuleHelper
170
- return XWModuleHelper
171
- elif name == "XWRuntimeHelper":
172
- from .runtime import XWRuntimeHelper
173
- return XWRuntimeHelper
174
- elif name == "manifest":
175
- # Import manifest module for lazy access
176
- from .package.services import manifest
177
- return manifest
178
- raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
179
-
180
- # Import core classes for advanced usage
181
- from .package.services.config_manager import LazyInstallConfig
182
- from .package.services import LazyInstallerRegistry, AsyncInstallHandle, LazyInstaller
183
- from .common.services.dependency_mapper import DependencyMapper
184
- from .module.importer_engine import (
185
- LazyMetaPathFinder,
186
- WatchedPrefixRegistry,
187
- LazyLoader,
188
- )
189
- from .package.services.manifest import LazyManifestLoader, PackageManifest
190
- from .facade import _lazy_importer
191
-
192
- # Import internal utilities (for advanced usage)
193
- from .common.services import (
194
- check_package_keywords,
195
- _detect_lazy_installation,
196
- _detect_meta_info_mode,
197
- )
198
- from .module.importer_engine import (
199
- _set_package_class_hints,
200
- _get_package_class_hints,
201
- _clear_all_package_class_hints,
202
- _spec_for_existing_module,
203
- )
204
- from .common.services.spec_cache import (
205
- _cached_stdlib_check,
206
- _spec_cache_get,
207
- _spec_cache_put,
208
- _spec_cache_clear,
209
- _cache_spec_if_missing,
210
- _spec_cache_prune_locked,
211
- )
212
- from .package.services import (
213
- is_externally_managed as _is_externally_managed,
214
- check_pip_audit_available as _check_pip_audit_available,
215
- )
216
- from .module.importer_engine import (
217
- _is_import_in_progress,
218
- _mark_import_started,
219
- _mark_import_finished,
220
- _lazy_aware_import_module,
221
- # _patch_import_module removed - deprecated, use sys.meta_path hooks instead
222
- _unpatch_import_module,
223
- )
224
-
225
- # Version info
226
- __author__ = 'Eng. Muhammad AlShehri'
227
- __email__ = 'connect@exonware.com'
228
- __company__ = 'eXonware.com'
229
-
230
- # =============================================================================
231
- # PUBLIC API
232
- # =============================================================================
233
-
234
- __all__ = [
235
- # Version
236
- "__version__",
237
- "VERSION_MAJOR",
238
- "VERSION_MINOR",
239
- "VERSION_PATCH",
240
- "VERSION_BUILD",
241
- "VERSION_SUFFIX",
242
- "VERSION_STRING",
243
- "get_version",
244
- "get_version_info",
245
- "get_version_dict",
246
- "is_dev_version",
247
- "is_release_version",
248
- # Facade functions
249
- "enable_lazy_mode",
250
- "disable_lazy_mode",
251
- "is_lazy_mode_enabled",
252
- "get_lazy_mode_stats",
253
- "configure_lazy_mode",
254
- "preload_modules",
255
- "optimize_lazy_mode",
256
- # One-line activation API
257
- "auto_enable_lazy",
258
- # Lazy-loader compatible API
259
- "attach",
260
- # Public API functions
261
- "enable_lazy_install",
262
- "disable_lazy_install",
263
- "is_lazy_install_enabled",
264
- "set_lazy_install_mode",
265
- "get_lazy_install_mode",
266
- "install_missing_package",
267
- "install_and_import",
268
- "get_lazy_install_stats",
269
- "get_all_lazy_install_stats",
270
- "lazy_import_with_install",
271
- "xwimport",
272
- # Hook functions
273
- "install_import_hook",
274
- "uninstall_import_hook",
275
- "is_import_hook_installed",
276
- # Lazy loading functions
277
- "enable_lazy_imports",
278
- "disable_lazy_imports",
279
- "is_lazy_import_enabled",
280
- "lazy_import",
281
- "register_lazy_module",
282
- "preload_module",
283
- "get_lazy_module",
284
- "get_loading_stats",
285
- "preload_frequently_used",
286
- "get_lazy_import_stats",
287
- # Configuration
288
- "config_package_lazy_install_enabled",
289
- "sync_manifest_configuration",
290
- "refresh_lazy_manifests",
291
- # Security & Policy
292
- "set_package_allow_list",
293
- "set_package_deny_list",
294
- "add_to_package_allow_list",
295
- "add_to_package_deny_list",
296
- "set_package_index_url",
297
- "set_package_extra_index_urls",
298
- "add_package_trusted_host",
299
- "set_package_lockfile",
300
- "generate_package_sbom",
301
- "check_externally_managed_environment",
302
- "register_lazy_module_prefix",
303
- "register_lazy_module_methods",
304
- # Keyword-based detection
305
- "enable_keyword_detection",
306
- "is_keyword_detection_enabled",
307
- "get_keyword_detection_keyword",
308
- "check_package_keywords",
309
- # Discovery functions
310
- "get_lazy_discovery",
311
- "discover_dependencies",
312
- "export_dependency_mappings",
313
- # Contracts
314
- "LazyLoadMode",
315
- "LazyInstallMode",
316
- "PathType",
317
- "DependencyInfo",
318
- "LazyModeConfig",
319
- "PRESET_MODES",
320
- "get_preset_mode",
321
- "IPackageHelper",
322
- "IModuleHelper",
323
- "IRuntime",
324
- # Abstract base classes
325
- "APackageHelper",
326
- "AModuleHelper",
327
- "ARuntimeHelper",
328
- # Concrete implementations
329
- "XWPackageHelper",
330
- "XWModuleHelper",
331
- "XWRuntimeHelper",
332
- # Errors
333
- "LazySystemError",
334
- "LazyInstallError",
335
- "LazyDiscoveryError",
336
- "LazyHookError",
337
- "LazySecurityError",
338
- "ExternallyManagedError",
339
- "DeferredImportError",
340
- # Config
341
- "LazyConfig",
342
- "DEFAULT_LAZY_CONFIG",
343
- # Core classes (for advanced usage)
344
- "LazyInstallConfig",
345
- "LazyInstallerRegistry",
346
- "AsyncInstallHandle",
347
- "LazyInstaller",
348
- "DependencyMapper",
349
- "LazyMetaPathFinder",
350
- "WatchedPrefixRegistry",
351
- "LazyLoader",
352
- "LazyManifestLoader",
353
- "PackageManifest",
354
- "manifest",
355
- "_lazy_importer",
356
- # Internal utilities (for advanced usage)
357
- "check_package_keywords",
358
- "_detect_lazy_installation",
359
- "_detect_meta_info_mode",
360
- "_set_package_class_hints",
361
- "_get_package_class_hints",
362
- "_clear_all_package_class_hints",
363
- "_spec_for_existing_module",
364
- "_cached_stdlib_check",
365
- "_spec_cache_get",
366
- "_spec_cache_put",
367
- "_spec_cache_clear",
368
- "_cache_spec_if_missing",
369
- "_spec_cache_prune_locked",
370
- "_is_externally_managed",
371
- "_check_pip_audit_available",
372
- "_is_import_in_progress",
373
- "_mark_import_started",
374
- "_mark_import_finished",
375
- "_lazy_aware_import_module",
376
- # "_patch_import_module", # Removed - deprecated, use sys.meta_path hooks instead
377
- "_unpatch_import_module",
378
- ]
379
-
@@ -1,55 +0,0 @@
1
- """
2
- #exonware/xwlazy/src/exonware/xwlazy/common/__init__.py
3
-
4
- Common utilities shared across package, module, and runtime.
5
-
6
- Company: eXonware.com
7
- Author: Eng. Muhammad AlShehri
8
- Email: connect@exonware.com
9
-
10
- Generation Date: 15-Nov-2025
11
- """
12
-
13
- from .logger import (
14
- get_logger,
15
- log_event,
16
- print_formatted,
17
- format_message,
18
- is_log_category_enabled,
19
- set_log_category,
20
- set_log_categories,
21
- get_log_categories,
22
- XWLazyFormatter,
23
- )
24
-
25
- from .cache import (
26
- MultiTierCache,
27
- BytecodeCache,
28
- InstallationCache,
29
- )
30
-
31
- from .utils import (
32
- find_project_root,
33
- find_config_file,
34
- )
35
-
36
- __all__ = [
37
- # Logger
38
- 'get_logger',
39
- 'log_event',
40
- 'print_formatted',
41
- 'format_message',
42
- 'is_log_category_enabled',
43
- 'set_log_category',
44
- 'set_log_categories',
45
- 'get_log_categories',
46
- 'XWLazyFormatter',
47
- # Cache
48
- 'MultiTierCache',
49
- 'BytecodeCache',
50
- 'InstallationCache',
51
- # Utils
52
- 'find_project_root',
53
- 'find_config_file',
54
- ]
55
-
@@ -1,65 +0,0 @@
1
- """
2
- Common Abstract Base Classes
3
-
4
- Company: eXonware.com
5
- Author: Eng. Muhammad AlShehri
6
- Email: connect@exonware.com
7
-
8
- Generation Date: 15-Nov-2025
9
-
10
- Abstract base classes for shared/common strategies.
11
- """
12
-
13
- from abc import ABC, abstractmethod
14
- from typing import Optional, Any
15
- from ..contracts import ICachingStrategy, ICacheStrategy
16
-
17
- # =============================================================================
18
- # ABSTRACT CACHING STRATEGY
19
- # =============================================================================
20
-
21
- class ACachingStrategy(ICachingStrategy, ABC):
22
- """
23
- Abstract base class for caching strategies (legacy name).
24
-
25
- Note: Use ACacheStrategy for new code (ICacheStrategy interface).
26
- """
27
- pass
28
-
29
- class ACacheStrategy(ICacheStrategy, ABC):
30
- """
31
- Abstract base class for caching strategies.
32
-
33
- Works with ANY data type (modules, packages, etc.).
34
- All caching strategies must extend this class.
35
- """
36
-
37
- @abstractmethod
38
- def get(self, key: str) -> Optional[Any]:
39
- """Get value from cache."""
40
- ...
41
-
42
- @abstractmethod
43
- def set(self, key: str, value: Any) -> None:
44
- """Set value in cache."""
45
- ...
46
-
47
- @abstractmethod
48
- def invalidate(self, key: str) -> None:
49
- """Invalidate cached value."""
50
- ...
51
-
52
- @abstractmethod
53
- def clear(self) -> None:
54
- """Clear all cached values."""
55
- ...
56
-
57
- # =============================================================================
58
- # EXPORT ALL
59
- # =============================================================================
60
-
61
- __all__ = [
62
- 'ACachingStrategy', # Legacy name
63
- 'ACacheStrategy', # New name for ICacheStrategy interface
64
- ]
65
-