mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2026-08-09 08:04:45 +00:00
Part C of the dispatchers/thread-caps audit. Both LnurlEndpointCache and DesktopCachedRichTextParser were bounded caches backed by a LinkedHashMap behind a single monitor (@Synchronized / Collections.synchronizedMap with accessOrder). An access-order map structurally mutates on get, so every read took the lock — serializing all readers on paths that are hot (kind-9735 zap-receipt validation; feed rich-text rendering). Add ConcurrentLruCache<K, V> in quartz utils: storage is a ConcurrentHashMap so get is lock-free; writes + eviction run under a small write lock that is off the read path. Eviction is least-recently-put order (get does not refresh recency) — exactly what LnurlEndpointCache already did, and fine for the deterministic rich-text parse cache. Point both caches at the shared helper. Covered by a new ConcurrentLruCacheTest (round-trip, eviction order, re-put recency refresh, get-does-not-refresh, clear, and a concurrent size-bound smoke test); the existing LnurlEndpointCacheTest still passes unchanged. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ANuUziXKRafSTBxbh4SMoq