Package org.opencms.monitor
Class CmsGroupListCache
- java.lang.Object
-
- org.opencms.monitor.CmsGroupListCache
-
- All Implemented Interfaces:
I_CmsMemoryMonitorable
public class CmsGroupListCache extends java.lang.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 Summary
Fields Modifier and Type Field Description static int
GROUP_LISTS_PER_USER
Max cached group lists per user.
-
Constructor Summary
Constructors Constructor Description CmsGroupListCache(int size)
Creates a new cache instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
Removes all cache entries.void
clearUser(CmsUUID idKey)
Removes the cache entries for the given user id.java.util.List<CmsRole>
getBareRoles(CmsUUID userId)
Gets the cached bare roles for the given user id, or null if none are cached.java.util.List<CmsGroup>
getGroups(CmsUUID userId, java.lang.String subKey)
Gets the cached user groups for the given combination of keys, or null if nothing is cached.java.lang.Boolean
getHasRole(CmsUUID userId, java.lang.String roleKey)
Gets the cached role membership for the given role key, or null if nothing is cached.int
getMemorySize()
Returns the memory size of the object.void
setBareRoles(CmsUser user, java.util.List<CmsRole> bareRoles)
Sets the bare roles for a user (with no OU information).void
setGroups(CmsUser user, java.lang.String subKey, java.util.List<CmsGroup> groups)
Caches a new value for the given combination of keys.void
setHasRole(CmsUser user, java.lang.String roleKey, java.lang.Boolean value)
Caches the role membership for the given user id and role key.int
size()
Returns the number of user ids for which group lists are cached.
-
-
-
Field Detail
-
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 Detail
-
CmsGroupListCache
public CmsGroupListCache(int size)
Creates a new cache instance.- Parameters:
size
- the maximum size
-
-
Method Detail
-
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 java.util.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 java.util.List<CmsGroup> getGroups(CmsUUID userId, java.lang.String subKey)
Gets the cached user groups for the given combination of keys, or null if nothing is cached.- Parameters:
userId
- the user idsubKey
- a string that consists of the parameters/flags for the group reading operation- Returns:
- the groups for the given combination of keys
-
getHasRole
public java.lang.Boolean getHasRole(CmsUUID userId, java.lang.String roleKey)
Gets the cached role membership for the given role key, or null if nothing is cached.- Parameters:
userId
- the user idroleKey
- 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 interfaceI_CmsMemoryMonitorable
- Returns:
- the memory size of the object
- See Also:
I_CmsMemoryMonitorable.getMemorySize()
-
setBareRoles
public void setBareRoles(CmsUser user, java.util.List<CmsRole> bareRoles)
Sets the bare roles for a user (with no OU information).- Parameters:
user
- the userbareRoles
- the list of bare roles
-
setGroups
public void setGroups(CmsUser user, java.lang.String subKey, java.util.List<CmsGroup> groups)
Caches a new value for the given combination of keys.- Parameters:
user
- the usersubKey
- a string that consists of the parameters/flags for the group reading operationgroups
- the value to cache
-
setHasRole
public void setHasRole(CmsUser user, java.lang.String roleKey, java.lang.Boolean value)
Caches the role membership for the given user id and role key.- Parameters:
user
- the userroleKey
- the role keyvalue
- 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
-
-