Package com.plotsquared.core.uuid
Class CacheUUIDService
java.lang.Object
com.plotsquared.core.uuid.CacheUUIDService
- All Implemented Interfaces:
UUIDService,Consumer<List<UUIDMapping>>
UUID service backed by a Guava Cache
-
Constructor Summary
ConstructorsConstructorDescriptionCacheUUIDService(int size) Construct a new Cache UUID service with a maximum number of entries. -
Method Summary
Modifier and TypeMethodDescriptionvoidaccept(@NonNull List<@NonNull UUIDMapping> uuidMappings) booleanCheck whether or not this service can be safely used synchronously without blocking the server for an extended amount of time.Get as many UUID mappings as possible under the condition that the operation cannot be blocking (for an extended amount of time)getImmediately(@NonNull Object object) Get a single UUID mapping immediately, if possibleAttempt to complete the given requests.Attempt to complete the given requests.
-
Constructor Details
-
CacheUUIDService
public CacheUUIDService(int size) Construct a new Cache UUID service with a maximum number of entries. Because it stores the mappings in two ways, the actual number of entries is two times the specified size- Parameters:
size- Maximum number of entries
-
-
Method Details
-
getNames
Description copied from interface:UUIDServiceAttempt to complete the given requests. Returns the mappings that could be created by this server- Specified by:
getNamesin interfaceUUIDService- Parameters:
uuids- Requests- Returns:
- Completed requests
-
getUUIDs
Description copied from interface:UUIDServiceAttempt to complete the given requests. Returns the mappings that could be created by this server- Specified by:
getUUIDsin interfaceUUIDService- Parameters:
usernames- Requests- Returns:
- Completed requests
-
accept
- Specified by:
acceptin interfaceConsumer<List<UUIDMapping>>
-
getImmediately
Description copied from interface:UUIDServiceGet as many UUID mappings as possible under the condition that the operation cannot be blocking (for an extended amount of time)- Specified by:
getImmediatelyin interfaceUUIDService- Returns:
- All mappings that could be provided immediately
-
canBeSynchronous
public boolean canBeSynchronous()Description copied from interface:UUIDServiceCheck whether or not this service can be safely used synchronously without blocking the server for an extended amount of time.- Specified by:
canBeSynchronousin interfaceUUIDService- Returns:
trueif the service can be used synchronously
-
getImmediately
Description copied from interface:UUIDServiceGet a single UUID mapping immediately, if possible- Specified by:
getImmediatelyin interfaceUUIDService- Parameters:
object- Username (String) orUUID- Returns:
- Mapping, if it could be found immediately
-