Merge pull request 'Add api to enable caching for TypeMapper' (#10) from CMDAPICaching into master
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Reviewed-on: #10
Dieser Commit ist enthalten in:
Commit
47bd9af03e
@ -24,6 +24,7 @@ import lombok.EqualsAndHashCode;
|
|||||||
import lombok.experimental.UtilityClass;
|
import lombok.experimental.UtilityClass;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
@UtilityClass
|
@UtilityClass
|
||||||
@ -36,12 +37,16 @@ public class TabCompletionCache {
|
|||||||
|
|
||||||
void add(AbstractTypeMapper<?, ?> typeMapper, AbstractSWCommand.Cached cached) {
|
void add(AbstractTypeMapper<?, ?> typeMapper, AbstractSWCommand.Cached cached) {
|
||||||
if (cached != null) {
|
if (cached != null) {
|
||||||
TabCompletionCache.cached.add(typeMapper);
|
add(typeMapper, cached.global(), cached.cacheDuration(), cached.timeUnit());
|
||||||
if (cached.global()) TabCompletionCache.global.add(typeMapper);
|
|
||||||
TabCompletionCache.cacheDuration.put(typeMapper, cached.timeUnit().toMillis(cached.cacheDuration()));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void add(AbstractTypeMapper<?, ?> typeMapper, boolean global, long cacheDuration, TimeUnit timeUnit) {
|
||||||
|
TabCompletionCache.cached.add(typeMapper);
|
||||||
|
if (global) TabCompletionCache.global.add(typeMapper);
|
||||||
|
TabCompletionCache.cacheDuration.put(typeMapper, timeUnit.toMillis(cacheDuration));
|
||||||
|
}
|
||||||
|
|
||||||
@EqualsAndHashCode
|
@EqualsAndHashCode
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
private static class Key {
|
private static class Key {
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren