當前位置: 首頁>>代碼示例>>Java>>正文


Java Cache.get方法代碼示例

本文整理匯總了Java中org.apache.shiro.cache.Cache.get方法的典型用法代碼示例。如果您正苦於以下問題:Java Cache.get方法的具體用法?Java Cache.get怎麽用?Java Cache.get使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.shiro.cache.Cache的用法示例。


在下文中一共展示了Cache.get方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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);
	}
}
 
開發者ID:penggle,項目名稱:xproject,代碼行數:18,代碼來源:ShiroCacheServiceImpl.java

示例2: doGetAuthorizationInfo

import org.apache.shiro.cache.Cache; //導入方法依賴的package包/類
/**
 * Gets the AuthorizationInfo that matches a token.  This method is only called if the info is not already
 * cached by the realm, so this method does not need to perform any further caching.
 */
@Override
protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) {

    AuthorizationInfo authorizationInfo = getUncachedAuthorizationInfoFromPrincipals(principals);

    Cache<String, AuthorizationInfo> idAuthorizationCache = getAvailableIdAuthorizationCache();
    if (idAuthorizationCache != null) {
        // Proactively cache any ID authorization info not already in cache
        for (PrincipalWithRoles principal : getPrincipalsFromPrincipalCollection(principals)) {
            if (idAuthorizationCache.get(principal.getId()) == null) {
                cacheAuthorizationInfoById(principal.getId(), authorizationInfo);
            }
        }
    }

    return authorizationInfo;
}
 
開發者ID:bazaarvoice,項目名稱:emodb,代碼行數:22,代碼來源:ApiKeyRealm.java

示例3: getRolePermissions

import org.apache.shiro.cache.Cache; //導入方法依賴的package包/類
/**
 * Gets the permissions for a role.  If possible the permissions are cached for efficiency.
 */
protected Collection<Permission> getRolePermissions(String role) {
    if (role == null) {
        return null;
    }
    Cache<String, RolePermissionSet> cache = getAvailableRolesCache();

    if (cache == null) {
        return _permissionReader.getPermissions(PermissionIDs.forRole(role));
    }

    RolePermissionSet rolePermissionSet = cache.get(role);

    if (rolePermissionSet == null) {
        Set<Permission> permissions = _permissionReader.getPermissions(PermissionIDs.forRole(role));
        rolePermissionSet = new SimpleRolePermissionSet(permissions);
        cache.put(role, rolePermissionSet);
    }

    return rolePermissionSet.permissions();
}
 
開發者ID:bazaarvoice,項目名稱:emodb,代碼行數:24,代碼來源:ApiKeyRealm.java

示例4: testLazyCacheManagerCreationWithoutCallingInit

import org.apache.shiro.cache.Cache; //導入方法依賴的package包/類
@Test
public void testLazyCacheManagerCreationWithoutCallingInit() throws InterruptedException {
    CacheManager ehCacheManager = cacheManager.getCacheManager();
    assertNull(ehCacheManager);

    //don't call init here - the ehcache CacheManager should be lazily created
    //because of the default Shiro ehcache.xml file in the classpath.  Just acquire a cache:
    Cache<String, String> cache = cacheManager.getCache("test");

    //now assert that an internal CacheManager has been created:
    ehCacheManager = cacheManager.getCacheManager();
    assertNotNull(ehCacheManager);

    assertNotNull(cache);
    cache.put("hello", "world");
    String value = cache.get("hello");
    assertNotNull(value);
    assertEquals(value, "world");

    System.out.println("Conf: " + ehCacheManager.getConfiguration().getDiskStoreConfiguration().getPath());
    System.out.println("Name : " + ehCacheManager.getConfiguration().getName());

    ehCacheManager.shutdown();
}
 
開發者ID:nebrass,項目名稱:pairing-shiro-javaee7,代碼行數:25,代碼來源:EhCacheManagerTest.java

示例5: getCachedAuthenticationInfo

import org.apache.shiro.cache.Cache; //導入方法依賴的package包/類
/**
 * Returns any cached AuthenticationInfo corresponding to the specified token or {@code null} if there currently
 * isn't any cached data.
 *
 * @param token the token submitted during the authentication attempt.
 * @return any cached AuthenticationInfo corresponding to the specified token or {@code null} if there currently
 *         isn't any cached data.
 * @since 1.2
 */
private AuthenticationInfo getCachedAuthenticationInfo(AuthenticationToken token) {
    AuthenticationInfo info = null;

    Cache<Object, AuthenticationInfo> cache = getAvailableAuthenticationCache();
    if (cache != null && token != null) {
        log.trace("Attempting to retrieve the AuthenticationInfo from cache.");
        Object key = getAuthenticationCacheKey(token);
        info = cache.get(key);
        if (info == null) {
            log.trace("No AuthorizationInfo found in cache for key [{}]", key);
        } else {
            log.trace("Found cached AuthorizationInfo for key [{}]", key);
        }
    }

    return info;
}
 
開發者ID:xuegongzi,項目名稱:rabbitframework,代碼行數:27,代碼來源:AuthenticatingRealm.java

示例6: getAuthorizationInfoById

import org.apache.shiro.cache.Cache; //導入方法依賴的package包/類
/**
 * Gets the authorization info for a user by their ID.  If possible the value is cached for efficient lookup.
 */
@Nullable
private AuthorizationInfo getAuthorizationInfoById(String id) {
    AuthorizationInfo authorizationInfo;

    // Search the cache first
    Cache<String, AuthorizationInfo> idAuthorizationCache = getAvailableIdAuthorizationCache();

    if (idAuthorizationCache != null) {
        authorizationInfo = idAuthorizationCache.get(id);

        if (authorizationInfo != null) {
            // Check whether it is the stand-in "null" cached value
            if (authorizationInfo != _nullAuthorizationInfo) {
                _log.debug("Authorization info found cached for id {}", id);
                return authorizationInfo;
            } else {
                _log.debug("Authorization info previously cached as not found for id {}", id);
                return null;
            }
        }
    }

    authorizationInfo = getUncachedAuthorizationInfoById(id);
    cacheAuthorizationInfoById(id, authorizationInfo);
    return authorizationInfo;
}
 
開發者ID:bazaarvoice,項目名稱:emodb,代碼行數:30,代碼來源:ApiKeyRealm.java

示例7: getCacheValueObject

import org.apache.shiro.cache.Cache; //導入方法依賴的package包/類
public static Object getCacheValueObject(String key) {
	Cache<String, Object> cache = SpringContextHelper
			.getMemcache(SessionKeyConstant.SYSTEM_MEMCACHE_KEY);
	if (cache == null) {
		return null;
	}
	return cache.get(key);
}
 
開發者ID:wu560130911,項目名稱:MultimediaDesktop,代碼行數:9,代碼來源:MemCacheUtil.java

示例8: getFromCache

import org.apache.shiro.cache.Cache; //導入方法依賴的package包/類
private SimpleSession getFromCache(String sessionId) {
    final Cache<String, SimpleSession> cache = this.cache;
    return cache != null ? cache.get(sessionId) : null;
}
 
開發者ID:line,項目名稱:centraldogma,代碼行數:5,代碼來源:FileBasedSessionDAO.java

示例9: get

import org.apache.shiro.cache.Cache; //導入方法依賴的package包/類
/**
 * 獲取緩存的值
 * @param cacheName 緩存名稱
 * @param key 緩存key
 * @return
 */
@Override
public Object get(String cacheName,String key){
	Cache<Object, Object> cache = cacheManager.getCache(cacheName);
	return cache.get(key);
}
 
開發者ID:babymm,項目名稱:mumu,代碼行數:12,代碼來源:EHCacheManager.java

示例10: getCachedSession

import org.apache.shiro.cache.Cache; //導入方法依賴的package包/類
/**
 * Returns the Session with the specified id from the specified cache.  This method simply calls
 * {@code cache.get(sessionId)} and can be overridden by subclasses for custom acquisition behavior.
 *
 * @param sessionId the id of the session to acquire.
 * @param cache     the cache to acquire the session from
 * @return the cached session, or {@code null} if the session wasn't in the cache.
 */
protected Session getCachedSession(Serializable sessionId, Cache<Serializable, Session> cache) {
    return cache.get(sessionId);
}
 
開發者ID:xuegongzi,項目名稱:rabbitframework,代碼行數:12,代碼來源:CachingSessionDAO.java


注:本文中的org.apache.shiro.cache.Cache.get方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。