Skip to content

feat: add strategies as an adapter type#38

Merged
MikaAK merged 5 commits intomainfrom
feat/strategies
Mar 18, 2026
Merged

feat: add strategies as an adapter type#38
MikaAK merged 5 commits intomainfrom
feat/strategies

Conversation

@MikaAK
Copy link
Owner

@MikaAK MikaAK commented Mar 9, 2026

No description provided.

@MikaAK MikaAK force-pushed the feat/strategies branch 3 times, most recently from 9ffd721 to 7ab8357 Compare March 10, 2026 01:36
…ching

Introduce strategy adapters as a new adapter type that wraps underlying
cache adapters. When adapter is a tuple `{strategy_module, config}`,
generate strategy-specific code paths that:

- Pass strategy config separately to strategy module functions
- Skip term encoding/decoding (delegated to strategy layer)
- Inject `__cache_module__` into adapter options for strategy use
- Validate strategy-specific options at compile time
@MikaAK MikaAK force-pushed the feat/strategies branch 3 times, most recently from 31747dd to 7f289cf Compare March 18, 2026 00:32
@codecov
Copy link

codecov bot commented Mar 18, 2026

Codecov Report

❌ Patch coverage is 82.45614% with 50 lines in your changes missing coverage. Please review.
✅ Project coverage is 75.50%. Comparing base (c92b310) to head (6448b08).
⚠️ Report is 34 commits behind head on main.

Files with missing lines Patch % Lines
lib/cache/hash_ring/ring_monitor.ex 55.55% 12 Missing ⚠️
lib/cache/hash_ring.ex 84.93% 11 Missing ⚠️
lib/cache/refresh_ahead.ex 85.33% 11 Missing ⚠️
lib/cache/counter.ex 88.00% 6 Missing ⚠️
lib/cache/multi_layer.ex 87.80% 5 Missing ⚠️
lib/cache/persistent_term.ex 72.72% 3 Missing ⚠️
lib/cache/strategy.ex 66.66% 2 Missing ⚠️

❗ There is a different number of reports uploaded between BASE (c92b310) and HEAD (6448b08). Click for more details.

HEAD has 1 upload less than BASE
Flag BASE (c92b310) HEAD (6448b08)
2 1
Additional details and impacted files
@@             Coverage Diff             @@
##             main      #38       +/-   ##
===========================================
- Coverage   87.17%   75.50%   -11.68%     
===========================================
  Files          10       20       +10     
  Lines         195      592      +397     
===========================================
+ Hits          170      447      +277     
- Misses         25      145      +120     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Add two new cache adapters:

- Cache.PersistentTerm: stores rarely-written, frequently-read values in
  :persistent_term for extremely fast reads. Does not support TTL.
- Cache.Counter: atomic integer counters backed by :counters module with
  lock-free operations. Stores counter reference and key-to-index mapping
  in :persistent_term. Provides increment/decrement functions and
  dynamically grows counter array as needed.

Update GitHub Actions
@MikaAK MikaAK merged commit 8f72424 into main Mar 18, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant