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 TypeMethodDescriptionvoid
accept(@NonNull List<@NonNull UUIDMapping> uuidMappings)
boolean
Check whether or not this service can be safely used synchronously without blocking the server for an extended amount of time.@NonNull Collection<@NonNull UUIDMapping>
Get as many UUID mappings as possible under the condition that the operation cannot be blocking (for an extended amount of time)@Nullable UUIDMapping
getImmediately(@NonNull Object object)
Get a single UUID mapping immediately, if possible@NonNull List<UUIDMapping>
Attempt to complete the given requests.@NonNull List<UUIDMapping>
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:UUIDService
Attempt to complete the given requests. Returns the mappings that could be created by this server- Specified by:
getNames
in interfaceUUIDService
- Parameters:
uuids
- Requests- Returns:
- Completed requests
-
getUUIDs
Description copied from interface:UUIDService
Attempt to complete the given requests. Returns the mappings that could be created by this server- Specified by:
getUUIDs
in interfaceUUIDService
- Parameters:
usernames
- Requests- Returns:
- Completed requests
-
accept
- Specified by:
accept
in interfaceConsumer<List<UUIDMapping>>
-
getImmediately
Description copied from interface:UUIDService
Get as many UUID mappings as possible under the condition that the operation cannot be blocking (for an extended amount of time)- Specified by:
getImmediately
in interfaceUUIDService
- Returns:
- All mappings that could be provided immediately
-
canBeSynchronous
public boolean canBeSynchronous()Description copied from interface:UUIDService
Check whether or not this service can be safely used synchronously without blocking the server for an extended amount of time.- Specified by:
canBeSynchronous
in interfaceUUIDService
- Returns:
- True if the service can be used synchronously
-
getImmediately
Description copied from interface:UUIDService
Get a single UUID mapping immediately, if possible- Specified by:
getImmediately
in interfaceUUIDService
- Parameters:
object
- Username (String
) orUUID
- Returns:
- Mapping, if it could be found immediately
-