java.lang.Object
net.i2p.router.web.helpers.NetDbRouterCache

class NetDbRouterCacheextends Object
Cached snapshot of the network database sorted by RouterInfoComparator.

The /netdb page auto-refreshes every 10 seconds (netdb.js REFRESH_INTERVAL_SHORT), so a snapshot up to this age is never visible to a client; caching it avoids re-sorting the full network database on every render.

  • Field Details

    • NETDB_REFRESH_PERIOD

      private static final long NETDB_REFRESH_PERIOD
      How long the router list is reused - 10 seconds.
      See Also:
    • _routersCachedUntil

      private static volatile long _routersCachedUntil
      When the cached list stops being usable.
    • _cachedRouters

      private static volatile List<RouterInfo> _cachedRouters
      The routers read last time.
    • _context

      private final RouterContext _context
      The router whose netdb is read.
  • Constructor Details

    • NetDbRouterCache

      public NetDbRouterCache(RouterContext ctx)
      Create an empty cache.
      Parameters:
      ctx - the router context
  • Method Details

    • getSortedRouters

      public List<RouterInfo> getSortedRouters()
      Snapshot of the network database sorted by RouterInfoComparator, cached for the /netdb auto-refresh period.
      Returns:
      every known RouterInfo in comparator order; never null, but may be empty before the router has learned about any peers