Package org.wildfly.security.cache
Class LRURealmIdentityCache
- java.lang.Object
-
- org.wildfly.security.cache.LRURealmIdentityCache
-
- All Implemented Interfaces:
RealmIdentityCache
public final class LRURealmIdentityCache extends Object implements RealmIdentityCache
ARealmIdentityCacheimplementation providing a LRU cache.- Author:
- Pedro Igor
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classLRURealmIdentityCache.CacheEntry
-
Field Summary
Fields Modifier and Type Field Description private static floatDEFAULT_LOAD_FACTORThe load factor.private Map<Principal,Set<Principal>>domainPrincipalMapHolds a mapping between a realm principal and domain principalsprivate Map<Principal,LRURealmIdentityCache.CacheEntry>identityCacheHolds the cached identitys where the key is the domain principal, the one used to lookup the identityprivate longmaxAgeprivate AtomicBooleanwriting
-
Constructor Summary
Constructors Constructor Description LRURealmIdentityCache(int maxEntries)Creates a new instance.LRURealmIdentityCache(int maxEntries, long maxAge)Creates a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()Removes all cached identities from this cache.RealmIdentityget(Principal key)Obtains a previously cachedRealmIdentityornullif no entry could be found with the specifiedPrincipal.private booleanparkForReadAndCheckInterrupt()private booleanparkForWriteAndCheckInterrupt()voidput(Principal key, RealmIdentity newValue)Puts a newRealmIdentityinto the cache and referenced by the specifiedPrincipal.voidremove(Principal key)Removes a specific cached identity from the cache and referenced by the specifiedPrincipal.private RealmIdentityremoveIfExpired(LRURealmIdentityCache.CacheEntry cached)-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.wildfly.security.cache.RealmIdentityCache
computeIfAbsent
-
-
-
-
Field Detail
-
DEFAULT_LOAD_FACTOR
private static final float DEFAULT_LOAD_FACTOR
The load factor.- See Also:
- Constant Field Values
-
identityCache
private final Map<Principal,LRURealmIdentityCache.CacheEntry> identityCache
Holds the cached identitys where the key is the domain principal, the one used to lookup the identity
-
domainPrincipalMap
private final Map<Principal,Set<Principal>> domainPrincipalMap
Holds a mapping between a realm principal and domain principals
-
writing
private final AtomicBoolean writing
-
maxAge
private final long maxAge
-
-
Constructor Detail
-
LRURealmIdentityCache
public LRURealmIdentityCache(int maxEntries)
Creates a new instance.- Parameters:
maxEntries- the maximum number of entries to keep in the cache
-
LRURealmIdentityCache
public LRURealmIdentityCache(int maxEntries, long maxAge)Creates a new instance.- Parameters:
maxEntries- the maximum number of entries to keep in the cachemaxAge- the time in milliseconds that an entry can stay in the cache. If-1, entries never expire
-
-
Method Detail
-
put
public void put(Principal key, RealmIdentity newValue)
Description copied from interface:RealmIdentityCachePuts a newRealmIdentityinto the cache and referenced by the specifiedPrincipal.- Specified by:
putin interfaceRealmIdentityCache- Parameters:
key- thePrincipalthat references the realm identity being cachednewValue- theRealmIdentityinstance
-
get
public RealmIdentity get(Principal key)
Description copied from interface:RealmIdentityCacheObtains a previously cachedRealmIdentityornullif no entry could be found with the specifiedPrincipal.- Specified by:
getin interfaceRealmIdentityCache- Parameters:
key- thePrincipalthat references a previously cached realm identity- Returns:
- a cached
RealmIdentityinstance ornullif no entry could be found with the specifiedprincipal.
-
remove
public void remove(Principal key)
Description copied from interface:RealmIdentityCacheRemoves a specific cached identity from the cache and referenced by the specifiedPrincipal.- Specified by:
removein interfaceRealmIdentityCache- Parameters:
key- thePrincipalthat references a previously cached realm identity
-
clear
public void clear()
Description copied from interface:RealmIdentityCacheRemoves all cached identities from this cache.- Specified by:
clearin interfaceRealmIdentityCache
-
removeIfExpired
private RealmIdentity removeIfExpired(LRURealmIdentityCache.CacheEntry cached)
-
parkForWriteAndCheckInterrupt
private boolean parkForWriteAndCheckInterrupt()
-
parkForReadAndCheckInterrupt
private boolean parkForReadAndCheckInterrupt()
-
-