Class CacheUUIDService

java.lang.Object
com.plotsquared.core.uuid.CacheUUIDService
All Implemented Interfaces:
UUIDService, Consumer<List<UUIDMapping>>

public class CacheUUIDService extends Object implements UUIDService, Consumer<List<UUIDMapping>>
UUID service backed by a Guava Cache
  • 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

      public @NonNull List<UUIDMapping> getNames(@NonNull List<@NonNull UUID> uuids)
      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 interface UUIDService
      Parameters:
      uuids - Requests
      Returns:
      Completed requests
    • getUUIDs

      public @NonNull List<UUIDMapping> getUUIDs(@NonNull List<@NonNull String> usernames)
      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 interface UUIDService
      Parameters:
      usernames - Requests
      Returns:
      Completed requests
    • accept

      public void accept(@NonNull List<@NonNull UUIDMapping> uuidMappings)
      Specified by:
      accept in interface Consumer<List<UUIDMapping>>
    • getImmediately

      public @NonNull Collection<@NonNull 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 interface UUIDService
      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 interface UUIDService
      Returns:
      True if the service can be used synchronously
    • getImmediately

      public @Nullable UUIDMapping getImmediately(@NonNull Object object)
      Description copied from interface: UUIDService
      Get a single UUID mapping immediately, if possible
      Specified by:
      getImmediately in interface UUIDService
      Parameters:
      object - Username (String) or UUID
      Returns:
      Mapping, if it could be found immediately