Interface CachedPermissionManagement

All Superinterfaces:
PermissionManagement
All Known Implementing Classes:
DefaultCachedPermissionManagement

public interface CachedPermissionManagement extends PermissionManagement
Represents a permission management instance which maintains a cache for permission users and groups internally to allow faster loading times (for example looking up the user in the cache rather than the database).
Since:
4.0
See Also:
  • Method Details

    • cachedPermissionUsers

      @NonNull @NonNull Map<UUID,PermissionUser> cachedPermissionUsers()
      Gets a map with all cached permission users mapped to their uuid.
      Returns:
      all cached permission users.
    • cachedPermissionGroups

      @NonNull @NonNull Map<String,PermissionGroup> cachedPermissionGroups()
      Gets a map with all cached permission groups mapped to their name.
      Returns:
      all cached permission groups.
    • cachedUser

      Searches the permission user cache for a permission user with the given unique id.
      Parameters:
      uniqueId - the unique id associated with the permission user.
      Returns:
      the cached permission user for the given unique id, null if no user was found in the cache.
      Throws:
      NullPointerException - if the given unique id is null.
    • cachedGroup

      Searches the permission group cache for a permission group with the given name.
      Parameters:
      name - the name associated with the permission group.
      Returns:
      the cached permission group for the given name, null if no group was found in the cache.
      Throws:
      NullPointerException - if the given name is null.
    • acquireLock

      void acquireLock(@NonNull @NonNull PermissionUser user)
      Acquires a lock for the permission user. The lock ensures that the user stays in cache.

      Each method call results in incrementing the lock count of the user. It's ensured that the user stays in the cache until the lock count is decreased again and reaches 0. After that event the normal cache invalidation rules of the permission management take effect again.

      Parameters:
      user - the user to acquire the lock for.
      Throws:
      NullPointerException - if the given user is null.
    • acquireLock

      void acquireLock(@NonNull @NonNull PermissionGroup group)
      Acquires a lock for the permission group. The lock ensures that the group stays in cache.

      Each method call results in incrementing the lock count of the group. It's ensured that the group stays in the cache until the lock count is decreased again and reaches 0. After that event the normal cache invalidation rules of the permission management take effect again.

      Parameters:
      group - the group to acquire the lock for.
      Throws:
      NullPointerException - if the given group is null.
    • locked

      boolean locked(@NonNull @NonNull PermissionUser user)
      Checks if the given user has any locks locking the user in the cache.
      Parameters:
      user - the user to check for locks.
      Returns:
      true if there are any locks for the given user, false otherwise.
      Throws:
      NullPointerException - if the given user is null.
    • locked

      boolean locked(@NonNull @NonNull PermissionGroup group)
      Checks if the given group has any locks locking the group in the cache.
      Parameters:
      group - the group to check for locks.
      Returns:
      true if there are any locks for the given group, false otherwise.
      Throws:
      NullPointerException - if the given group is null.
    • unlock

      void unlock(@NonNull @NonNull PermissionUser user)
      Removes exactly one lock of the user. If the user does not have any locks no changes are made. It's ensured that the user stays in the cache until the lock count is decreased again and reaches 0. After that event the normal cache invalidation rules of the permission management take effect again.
      Parameters:
      user - the user to remove a lock for.
      Throws:
      NullPointerException - if the given user is null.
    • unlock

      void unlock(@NonNull @NonNull PermissionGroup group)
      Removes exactly one lock of the group. If the group does not have any locks no changes are made. It's ensured that the group stays in the cache until the lock count is decreased again and reaches 0. After that event the normal cache invalidation rules of the permission management take effect again.
      Parameters:
      group - the group to remove a lock for.
      Throws:
      NullPointerException - if the given group is null.
    • unlockFully

      void unlockFully(@NonNull @NonNull PermissionUser user)
      Removes all locks that the given user has. After that event the normal cache invalidation rules of the permission management take effect again.
      Parameters:
      user - the user to unlock completely.
      Throws:
      NullPointerException - if the given user is null.
    • unlockFully

      void unlockFully(@NonNull @NonNull PermissionGroup group)
      Removes all locks that the given group has. After that event the normal cache invalidation rules of the permission management take effect again.
      Parameters:
      group - the group to unlock completely.
      Throws:
      NullPointerException - if the given group is null.