Class ServerCache
java.lang.Object
com.realtime.crossfire.jxclient.metaserver.ServerCache
Maintains a set of known servers backed up in a file.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final @NotNull CharSequenceThe default entry for the "localhost" server. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidexpire(long timestamp) Expires entries older than a given timestamp from the cache.@NotNull Map<String,MetaserverEntry> getAll()Returns all cached entries.voidput(@NotNull MetaserverEntry metaserverEntry) Adds an entry to the cache.voidsave()Saves all entries to the backing file.
-
Field Details
-
DEFAULT_ENTRY_LOCALHOST
The default entry for the "localhost" server.
-
-
Constructor Details
-
ServerCache
Creates a new instance.- Parameters:
file- the backing file ornullto not cache on disk
-
-
Method Details
-
put
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
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.
-