public class ServerCache
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static @NotNull java.lang.CharSequence |
DEFAULT_ENTRY_LOCALHOST
The default entry for the "localhost" server.
|
Constructor and Description |
---|
ServerCache(@Nullable java.nio.file.Path file)
Creates a new instance.
|
Modifier and Type | Method and Description |
---|---|
void |
expire(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.
|
void |
put(@NotNull MetaserverEntry metaserverEntry)
Adds an entry to the cache.
|
void |
save()
Saves all entries to the backing file.
|
@NotNull public static final @NotNull java.lang.CharSequence DEFAULT_ENTRY_LOCALHOST
public ServerCache(@Nullable @Nullable java.nio.file.Path file)
file
- the backing file or null
to not cache on diskpublic void put(@NotNull @NotNull MetaserverEntry metaserverEntry)
metaserverEntry
- the entry to addpublic void expire(long timestamp)
timestamp
- the timestamp@NotNull public @NotNull java.util.Map<java.lang.String,MetaserverEntry> getAll()
public void save()