Skip to content

PR back to optum#1

Open
Esity wants to merge 116 commits into
Optum:mainfrom
LegionIO:main
Open

PR back to optum#1
Esity wants to merge 116 commits into
Optum:mainfrom
LegionIO:main

Conversation

@Esity

@Esity Esity commented Apr 17, 2026

Copy link
Copy Markdown
Member

No description provided.

Esity and others added 30 commits March 12, 2026 20:56
connection_pool >= 2.4, dalli >= 3.0, redis >= 5.0
- add cache_interface_spec.rb (15 tests for module API surface)
- add version_spec.rb (3 tests)
- expand settings_spec.rb (17 tests for defaults and driver selection)
- expand pool_spec.rb (6 tests with included module pattern)
- fix spec_helper load order (require settings before using it)
- 42 unit tests that always pass without Memcached/Redis
runs after ci passes on push to main. calls reusable release workflow
for version detection, github release, and rubygems publish.
dalli gem enforces a 1mb client-side size limit before sending to
memcached. this prevented large cache values (e.g. 11k+ memory traces)
from being stored even when the memcached server allows larger items.

v1.2.1
- README: 8MB value_max_bytes default, pool API, driver usage examples
- CLAUDE.md: memcached defaults, TTL signature differences
Also fix Local#restart to preserve local settings (namespace, etc.) by
merging local_settings as the base before applying caller-supplied opts.
Without this, restart dropped the legion_local namespace and wrote to
the shared namespace, breaking isolation.
Esity added 27 commits April 6, 2026 13:00
- refactor @connected to Concurrent::AtomicBoolean
- invert call graph: set_sync/delete_sync own mutation logic
- mset_sync holds mutex for atomic batch writes
- add mget/mset/mset_sync for interface consistency
- add exception handling on reads (get/fetch return nil)
- add lifecycle rescue (setup/shutdown/restart force connected=false)
- fix reset! race: make_false inside mutex before clearing store
- add enforce_phi_ttl with minimum 1s clamp
- add flush rescue returning false on error
- add restart method
…improvements

Phase A - adversarial review fixes:
- force helper and cacheable to use async: false for read-after-write consistency
- fix async writer TOCTOU race in enqueue (local executor reference)
- add failed_count to async writer stats
- fix reconnector deadlock, atomic reset, and missing require
- add reconnect_shared! raising method, start reconnector on any shared failure
- guard setup with enabled? check
- make async writer and reconnector tier-aware for settings
- apply serialization to redis mget/mset_sync, force binary encoding
- pass auth/TLS options to redis cluster flush per-node connections
- drain async writer before closing pools on shutdown

Phase B - connection pool improvements:
- remove hardcoded pool_size from redis driver, resolve from settings
- separate pool checkout timeout from operation timeout
- refactor state flags to Concurrent::AtomicBoolean for thread safety
- add public pool accessor, replace direct @client access in redis_hash
- add end-to-end lifecycle integration test
- add automatic failback to local when shared cache unavailable
- bump version to 1.4.1
apply post-optimization adversarial review fixes and pool improvements
Adds Legion::Cache.set_nx(key, value, ttl:) — a compare-and-set
primitive that returns true if the key was written (race won) and
false if the key already existed.

- Redis: conn.set(key, serialized, nx: true, ex: ttl)
- Memcached: conn.add(key, value, ttl) — native atomic add semantics
- Memory: mutex-guarded check-and-set with TTL expiry awareness
- Facade (Legion::Cache): routes to the active driver; falls back
  through local/memory tiers following the same pattern as set

Specs cover: win/lose semantics, TTL expiry, concurrency (10 threads),
  serialization pass-through, and the public interface contract.

Also fixes a pre-existing helper_spec JSON key assertion that broke
when Legion::JSON.dump switched to pretty-print output.
Fleet WS-00G: add Legion::Cache.set_nx
@Esity Esity requested review from a team and tylerkastenschmidt April 17, 2026 15:37
@Esity Esity self-assigned this Apr 17, 2026
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