Class ServerCache
- java.lang.Object
-
- com.realtime.crossfire.jxclient.metaserver.ServerCache
-
public class ServerCache extends java.lang.ObjectMaintains a set of known servers backed up in a file.
-
-
Field Summary
Fields Modifier and Type Field Description static @NotNull java.lang.CharSequenceDEFAULT_ENTRY_LOCALHOSTThe default entry for the "localhost" server.
-
Constructor Summary
Constructors Constructor Description ServerCache(@Nullable java.nio.file.Path file)Creates a new instance.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidexpire(long timestamp)Expires entries older than a given timestamp from the cache.@NotNull java.util.Map<java.lang.String,MetaserverEntry>getAll()Returns all cached entries.static @NotNull java.lang.StringmakeKey(@NotNull MetaserverEntry metaserverEntry)Returns the key for a metaserver entry.voidput(@NotNull MetaserverEntry metaserverEntry)Adds an entry to the cache.voidsave()Saves all entries to the backing file.
-
-
-
Method Detail
-
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 java.util.Map<java.lang.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
-
makeKey
@NotNull public static @NotNull java.lang.String makeKey(@NotNull @NotNull MetaserverEntry metaserverEntry)Returns the key for a metaserver entry.- Parameters:
metaserverEntry- the metaserver entry- Returns:
- the key
-
save
public void save()
Saves all entries to the backing file.
-
-