本文整理匯總了Java中org.apache.shiro.cache.Cache.remove方法的典型用法代碼示例。如果您正苦於以下問題:Java Cache.remove方法的具體用法?Java Cache.remove怎麽用?Java Cache.remove使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.shiro.cache.Cache
的用法示例。
在下文中一共展示了Cache.remove方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: crearCachedSessionInfo
import org.apache.shiro.cache.Cache; //導入方法依賴的package包/類
public void crearCachedSessionInfo(String principal) {
try {
logger.warn(">>> 清除用戶[{}]的會話緩存", principal);
String cacheName = sessionDAO.getActiveSessionsCacheName();
Cache<String,Object> cache = sessionDAO.getCacheManager().getCache(cacheName);
/**
* @see #SimpleSessionDAO
*/
String sessionId = (String) cache.get(principal);
if(!StringUtils.isEmpty(sessionId)){
cache.remove(sessionId);
cache.remove(principal);
}
} catch (Exception e) {
logger.error(String.format(">>> 清除用戶[%s]的會話緩存發生異常: %s", principal, e.getMessage()), e);
}
}
示例2: clearAllCachedAuthorizationInfo
import org.apache.shiro.cache.Cache; //導入方法依賴的package包/類
/**
* 清除所有用戶授權信息緩存.
*/
public void clearAllCachedAuthorizationInfo() {
if (logger.isDebugEnabled()) {
logger.debug("clearAllCachedAuthorizationInfo() - start"); //$NON-NLS-1$
}
Cache<Object, AuthorizationInfo> cache = getAuthorizationCache();
if (cache != null) {
for (Object key : cache.keys()) {
cache.remove(key);
}
}
if (logger.isDebugEnabled()) {
logger.debug("clearAllCachedAuthorizationInfo() - end"); //$NON-NLS-1$
}
}
示例3: clearAllCachedAuthorizationInfo
import org.apache.shiro.cache.Cache; //導入方法依賴的package包/類
/**
* 清除所有用戶授權信息緩存.
*/
public void clearAllCachedAuthorizationInfo() {
Cache<Object, AuthorizationInfo> cache = getAuthorizationCache();
if (cache != null) {
for (Object key : cache.keys()) {
cache.remove(key);
}
}
}
示例4: removeAll
import org.apache.shiro.cache.Cache; //導入方法依賴的package包/類
/**
* 從緩存中移除所有
*
* @param cacheName
*/
public static void removeAll(String cacheName) {
Cache<String, Object> cache = getCache(cacheName);
Set<String> keys = cache.keys();
for (Iterator<String> it = keys.iterator(); it.hasNext(); ) {
cache.remove(it.next());
}
logger.info("清理緩存: {} => {}", cacheName, keys);
}
示例5: remove
import org.apache.shiro.cache.Cache; //導入方法依賴的package包/類
/**
* 刪除緩存數據 緩存名稱
* @param cacheName 緩存key
* @param key
* @return
*/
@Override
public Object remove(String cacheName,String key){
Cache<Object, Object> cache = cacheManager.getCache(cacheName);
cacheManager.getCacheManager().removeCache(cacheName);
return cache.remove(key);
}
示例6: removeAll
import org.apache.shiro.cache.Cache; //導入方法依賴的package包/類
/**
* 從緩存中移除所有
* @param cacheName
*/
public static void removeAll(String cacheName) {
Cache<String, Object> cache = getCache(cacheName);
Set<String> keys = cache.keys();
for (Iterator<String> it = keys.iterator(); it.hasNext();){
cache.remove(it.next());
}
logger.info("清理緩存: {} => {}", cacheName, keys);
}
示例7: removeAll
import org.apache.shiro.cache.Cache; //導入方法依賴的package包/類
/**
* 從緩存中移除所有
*
* @param cacheName
*/
public static void removeAll(String cacheName) {
Cache<String, Object> cache = getCache(cacheName);
Set<String> keys = cache.keys();
for (Iterator<String> it = keys.iterator(); it.hasNext(); ) {
cache.remove(it.next());
}
logger.info("清理緩存: {} => {}", cacheName, keys);
}
示例8: uncache
import org.apache.shiro.cache.Cache; //導入方法依賴的package包/類
/**
* Removes the specified Session from the cache.
*
* @param session the session to remove from the cache.
*/
protected void uncache(Session session) {
if (session == null) {
return;
}
Serializable id = session.getId();
if (id == null) {
return;
}
Cache<Serializable, Session> cache = getActiveSessionsCacheLazy();
if (cache != null) {
cache.remove(id);
}
}
示例9: cleanAuthorizationCache
import org.apache.shiro.cache.Cache; //導入方法依賴的package包/類
public void cleanAuthorizationCache(String userId) {
String prefix = cacheKeyPrefix + authz_key + userId;
Cache<Object, AuthorizationInfo> cache = getAuthorizationCache();
if (cache != null) {
cache.remove(prefix);
}
}
示例10: clearAllCachedAuthorizationInfo
import org.apache.shiro.cache.Cache; //導入方法依賴的package包/類
public void clearAllCachedAuthorizationInfo() {
Cache<Object, AuthorizationInfo> cache = getAuthorizationCache();
if (cache != null) {
LOG.info("cache: {}", cache);
for (Object key : cache.keys()) {
LOG.info("remove {}", key);
cache.remove(key);
}
}
}
示例11: clearAllCachedAuthorizationInfo
import org.apache.shiro.cache.Cache; //導入方法依賴的package包/類
/**
* 清除所有用戶授權信息緩存.
*/
public void clearAllCachedAuthorizationInfo() {
Cache<Object, AuthorizationInfo> cache = getAuthorizationCache();
if (cache != null) {
for (Object key : cache.keys()) {
cache.remove(key);
}
}
}
示例12: deleteFromCache
import org.apache.shiro.cache.Cache; //導入方法依賴的package包/類
private void deleteFromCache(String sessionId) {
final Cache<String, SimpleSession> cache = this.cache;
if (cache != null) {
cache.remove(sessionId);
}
}
示例13: clearCachedAuthorizationInfo
import org.apache.shiro.cache.Cache; //導入方法依賴的package包/類
/**
* Clears out the AuthorizationInfo cache entry for the specified account.
* <p/>
* This method is provided as a convenience to subclasses so they can invalidate a cache entry when they
* change an account's authorization data (add/remove roles or permissions) during runtime. Because an account's
* AuthorizationInfo can be cached, there needs to be a way to invalidate the cache for only that account so that
* subsequent authorization operations don't used the (old) cached value if account data changes.
* <p/>
* After this method is called, the next authorization check for that same account will result in a call to
* {@link #getAuthorizationInfo(org.apache.shiro.subject.PrincipalCollection) getAuthorizationInfo}, and the
* resulting return value will be cached before being returned so it can be reused for later authorization checks.
* <p/>
* If you wish to clear out all associated cached data (and not just authorization data), use the
* {@link #clearCache(org.apache.shiro.subject.PrincipalCollection)} method instead (which will in turn call this
* method by default).
*
* @param principals the principals of the account for which to clear the cached AuthorizationInfo.
*/
protected void clearCachedAuthorizationInfo(PrincipalCollection principals) {
if (principals == null) {
return;
}
Cache<Object, AuthorizationInfo> cache = getAvailableAuthorizationCache();
//cache instance will be non-null if caching is enabled:
if (cache != null) {
Object key = getAuthorizationCacheKey(principals);
cache.remove(key);
}
}
示例14: clearCachedAuthenticationInfo
import org.apache.shiro.cache.Cache; //導入方法依賴的package包/類
/**
* Clears out the AuthenticationInfo cache entry for the specified account.
* <p/>
* This method is provided as a convenience to subclasses so they can invalidate a cache entry when they
* change an account's authentication data (e.g. reset password) during runtime. Because an account's
* AuthenticationInfo can be cached, there needs to be a way to invalidate the cache for only that account so that
* subsequent authentication operations don't used the (old) cached value if account data changes.
* <p/>
* After this method is called, the next authentication for that same account will result in a call to
* {@link #doGetAuthenticationInfo(org.apache.shiro.authc.AuthenticationToken) doGetAuthenticationInfo}, and the
* resulting return value will be cached before being returned so it can be reused for later authentications.
* <p/>
* If you wish to clear out all associated cached data (and not just authentication data), use the
* {@link #clearCache(org.apache.shiro.subject.PrincipalCollection)} method instead (which will in turn call this
* method by default).
*
* @param principals the principals of the account for which to clear the cached AuthorizationInfo.
* @see #clearCache(org.apache.shiro.subject.PrincipalCollection)
* @since 1.2
*/
protected void clearCachedAuthenticationInfo(PrincipalCollection principals) {
if (!CollectionUtils.isEmpty(principals)) {
Cache<Object, AuthenticationInfo> cache = getAvailableAuthenticationCache();
//cache instance will be non-null if caching is enabled:
if (cache != null) {
Object key = getAuthenticationCacheKey(principals);
cache.remove(key);
}
}
}