java.lang.Object com.realtime.crossfire.jxclient.metaserver.ServerCache
public class ServerCache
Maintains a set of known servers backed up in a file.
Field Summary | |
---|---|
static java.lang.CharSequence |
DEFAULT_ENTRY_LOCALHOST
The default entry for the "localhost" server. |
private java.util.Map<java.lang.String,Info> |
entries
The cached entries. |
private java.io.File |
file
The backing file. |
Constructor Summary | |
---|---|
ServerCache(java.io.File file)
Create a new instance. |
Method Summary | |
---|---|
private boolean |
addEntry(java.lang.CharSequence metaserverEntryLine,
long timestamp)
Parses a metaserver entry line and adds the result to entries . |
void |
expire(long timestamp)
Expire entries older than a given timestamp from the cache. |
java.util.Map<java.lang.String,MetaserverEntry> |
getAll()
Return all cached entries. |
private void |
load()
Load the entries from the backing file. |
static java.lang.String |
makeKey(MetaserverEntry metaserverEntry)
Return the key for a metaserver entry. |
void |
put(MetaserverEntry metaserverEntry)
Add an entry to the cache. |
void |
save()
Save all entries to the backing file. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
@NotNull public static final java.lang.CharSequence DEFAULT_ENTRY_LOCALHOST
@NotNull private final java.util.Map<java.lang.String,Info> entries
makeKey(MetaserverEntry)
) to
Info
instance for the metaserver entry.
@NotNull private final java.io.File file
Constructor Detail |
---|
public ServerCache(@NotNull java.io.File file)
file
- The backing file.Method Detail |
---|
private boolean addEntry(@NotNull java.lang.CharSequence metaserverEntryLine, long timestamp)
entries
.
metaserverEntryLine
- the metaserver entry line to parsetimestamp
- the query timestamp
public void expire(long timestamp)
timestamp
- The timestamp.@NotNull public java.util.Map<java.lang.String,MetaserverEntry> getAll()
private void load()
@NotNull public static java.lang.String makeKey(@NotNull MetaserverEntry metaserverEntry)
metaserverEntry
- The metaserver entry.
public void put(@NotNull MetaserverEntry metaserverEntry)
metaserverEntry
- The entry to add.public void save()