Class SpringCacheBasedUserCache
java.lang.Object
org.springframework.security.core.userdetails.cache.SpringCacheBasedUserCache
- All Implemented Interfaces:
UserCache
Caches
UserDetails
instances in a Spring defined Cache
.- Since:
- 3.2
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptiongetUserFromCache
(String username) Obtains aUserDetails
from the cache.void
putUserInCache
(UserDetails user) Places aUserDetails
in the cache.void
removeUserFromCache
(String username) Removes the specified user from the cache.void
-
Constructor Details
-
SpringCacheBasedUserCache
public SpringCacheBasedUserCache(org.springframework.cache.Cache cache)
-
-
Method Details
-
getUserFromCache
Description copied from interface:UserCache
Obtains aUserDetails
from the cache.- Specified by:
getUserFromCache
in interfaceUserCache
- Parameters:
username
- theUser.getUsername()
used to place the user in the cache- Returns:
- the populated
UserDetails
ornull
if the user could not be found or if the cache entry has expired
-
putUserInCache
Description copied from interface:UserCache
Places aUserDetails
in the cache. Theusername
is the key used to subsequently retrieve theUserDetails
.- Specified by:
putUserInCache
in interfaceUserCache
- Parameters:
user
- the fully populatedUserDetails
to place in the cache
-
removeUserFromCache
-
removeUserFromCache
Description copied from interface:UserCache
Removes the specified user from the cache. Theusername
is the key used to remove the user. If the user is not found, the method should simply return (not thrown an exception).Some cache implementations may not support eviction from the cache, in which case they should provide appropriate behaviour to alter the user in either its documentation, via an exception, or through a log message.
- Specified by:
removeUserFromCache
in interfaceUserCache
- Parameters:
username
- to be evicted from the cache
-