Class CmsGroupListCache

java.lang.Object
org.opencms.monitor.CmsGroupListCache
All Implemented Interfaces:
I_CmsMemoryMonitorable

public class CmsGroupListCache extends Object implements I_CmsMemoryMonitorable
Cache for users' groups and data derived from those groups, like role membership.

The cache can be either flushed completely, or just for a single user id. The data for a user must be flushed when their group membership changes.

  • Field Details

    • GROUP_LISTS_PER_USER

      public static volatile int GROUP_LISTS_PER_USER
      Max cached group lists per user. Non-final, so can be adjusted at runtime.
  • Constructor Details

    • CmsGroupListCache

      public CmsGroupListCache(int size)
      Creates a new cache instance.
      Parameters:
      size - the maximum size
  • Method Details

    • clear

      public void clear()
      Removes all cache entries.
    • clearUser

      public void clearUser(CmsUUID idKey)
      Removes the cache entries for the given user id.
      Parameters:
      idKey - the user id
    • getBareRoles

      public List<CmsRole> getBareRoles(CmsUUID userId)
      Gets the cached bare roles for the given user id, or null if none are cached.

      These are just the roles of the user, but with no OU information.

      Parameters:
      userId - the user id
      Returns:
      the bare roles for the user
    • getGroups

      public List<CmsGroup> getGroups(CmsUUID userId, String subKey)
      Gets the cached user groups for the given combination of keys, or null if nothing is cached.
      Parameters:
      userId - the user id
      subKey - a string that consists of the parameters/flags for the group reading operation
      Returns:
      the groups for the given combination of keys
    • getHasRole

      public Boolean getHasRole(CmsUUID userId, String roleKey)
      Gets the cached role membership for the given role key, or null if nothing is cached.
      Parameters:
      userId - the user id
      roleKey - the role key
      Returns:
      the cached role membership
    • getMemorySize

      public int getMemorySize()
      Description copied from interface: I_CmsMemoryMonitorable
      Returns the memory size of the object.

      Specified by:
      getMemorySize in interface I_CmsMemoryMonitorable
      Returns:
      the memory size of the object
      See Also:
    • setBareRoles

      public void setBareRoles(CmsUser user, List<CmsRole> bareRoles)
      Sets the bare roles for a user (with no OU information).
      Parameters:
      user - the user
      bareRoles - the list of bare roles
    • setGroups

      public void setGroups(CmsUser user, String subKey, List<CmsGroup> groups)
      Caches a new value for the given combination of keys.
      Parameters:
      user - the user
      subKey - a string that consists of the parameters/flags for the group reading operation
      groups - the value to cache
    • setHasRole

      public void setHasRole(CmsUser user, String roleKey, Boolean value)
      Caches the role membership for the given user id and role key.
      Parameters:
      user - the user
      roleKey - the role key
      value - the role membership value
    • size

      public int size()
      Returns the number of user ids for which group lists are cached.
      Returns:
      the number of user ids for which group lists are cached