Class ServerCache

java.lang.Object
com.realtime.crossfire.jxclient.metaserver.ServerCache

public class ServerCache extends Object
Maintains a set of known servers backed up in a file.
  • Field Details

    • DEFAULT_ENTRY_LOCALHOST

      @NotNull public static final @NotNull CharSequence DEFAULT_ENTRY_LOCALHOST
      The default entry for the "localhost" server.
  • Constructor Details

    • ServerCache

      public ServerCache(@Nullable @Nullable Path file)
      Creates a new instance.
      Parameters:
      file - the backing file or null to not cache on disk
  • Method Details

    • put

      public void put(@NotNull @NotNull MetaserverEntry metaserverEntry)
      Adds an entry to the cache. Overwrites old entries for the same hostname.
      Parameters:
      metaserverEntry - the entry to add
    • expire

      public void expire(long timestamp)
      Expires entries older than a given timestamp from the cache.
      Parameters:
      timestamp - the timestamp
    • getAll

      @NotNull public @NotNull Map<String,MetaserverEntry> getAll()
      Returns all cached entries. The returned set may be modified by the caller.
      Returns:
      the cached entries; maps key to metaserver entry
    • save

      public void save()
      Saves all entries to the backing file.