package com.sptmobile.endpoint import java.util.concurrent.ConcurrentHashMap /** * Process-lifetime endpoint id → serving-host node cache for the digest route * (DESIGN.md ruling 4). The route is decided by a ~2s `listEndpoints` call, * yet it almost never changes, so caching it lets a repeat open of an endpoint * paint its digest immediately instead of re-paying the routing round-trip. * * A stale entry (the endpoint moved, or the serving host went away) self-heals: * [EndpointViewModel] invalidates on any digest RPC failure, then re-routes * from a fresh listing. Small and unbounded — the paired-host fleet is tiny. */ object DigestRouteCache { private val routes = ConcurrentHashMap() fun get(endpointId: String): String? = routes[endpointId] fun put(endpointId: String, node: String) { routes[endpointId] = node } fun invalidate(endpointId: String) { routes.remove(endpointId) } }