Class SpringCacheBasedUserCache
- java.lang.Object
-
- org.springframework.security.core.userdetails.cache.SpringCacheBasedUserCache
-
- All Implemented Interfaces:
UserCache
public class SpringCacheBasedUserCache extends java.lang.Object implements UserCache
CachesUserDetailsinstances in a Spring definedCache.- Since:
- 3.2
-
-
Constructor Summary
Constructors Constructor Description SpringCacheBasedUserCache(org.springframework.cache.Cache cache)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description UserDetailsgetUserFromCache(java.lang.String username)Obtains aUserDetailsfrom the cache.voidputUserInCache(UserDetails user)Places aUserDetailsin the cache.voidremoveUserFromCache(java.lang.String username)Removes the specified user from the cache.voidremoveUserFromCache(UserDetails user)
-
-
-
Method Detail
-
getUserFromCache
public UserDetails getUserFromCache(java.lang.String username)
Description copied from interface:UserCacheObtains aUserDetailsfrom the cache.- Specified by:
getUserFromCachein interfaceUserCache- Parameters:
username- theUser.getUsername()used to place the user in the cache- Returns:
- the populated
UserDetailsornullif the user could not be found or if the cache entry has expired
-
putUserInCache
public void putUserInCache(UserDetails user)
Description copied from interface:UserCachePlaces aUserDetailsin the cache. Theusernameis the key used to subsequently retrieve theUserDetails.- Specified by:
putUserInCachein interfaceUserCache- Parameters:
user- the fully populatedUserDetailsto place in the cache
-
removeUserFromCache
public void removeUserFromCache(UserDetails user)
-
removeUserFromCache
public void removeUserFromCache(java.lang.String username)
Description copied from interface:UserCacheRemoves the specified user from the cache. Theusernameis 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:
removeUserFromCachein interfaceUserCache- Parameters:
username- to be evicted from the cache
-
-