Commit e9fec53
Add universal caching layer with get_or_set() method
Implements SimpleCache for drivers to minimize redundant SCPI calls
between polling loops and API requests.
Key features:
- Thread-safe caching with RLock
- TTL support with fractional seconds (e.g., 0.6s) or no expiry
- get_or_set() method for concise cache-or-compute pattern
- Hybrid support: direct values and callables
- Lazy expiry and metrics tracking (hits, misses, evictions)
Changes:
- Add cache.py: SimpleCache class with get_or_set() method
- Add test_cache.py: 40 unit tests covering all features
- Add test_owon_oel_caching.py: 11 integration tests
- Migrate owon_oel driver to use get_or_set() (75% code reduction)
- Add CACHE_DESIGN.md: comprehensive documentation
- Update CLAUDE.md: add caching to Key Modules and driver guide
Performance: 3x speedup in owon_oel polling, 10x reduction in SCPI calls
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>1 parent 8ba9e43 commit e9fec53
File tree
6 files changed
+1891
-12
lines changed- benchmesh-serial-service
- src/benchmesh_service
- drivers/owon_oel
- tests
6 files changed
+1891
-12
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
359 | 359 | | |
360 | 360 | | |
361 | 361 | | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
362 | 372 | | |
363 | 373 | | |
364 | 374 | | |
| |||
375 | 385 | | |
376 | 386 | | |
377 | 387 | | |
| 388 | + | |
378 | 389 | | |
379 | 390 | | |
380 | 391 | | |
| |||
0 commit comments