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


Java Cache.put方法代碼示例

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


在下文中一共展示了Cache.put方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: 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

示例2: 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

示例3: put

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

示例4: cacheAuthorizationInfoById

import org.apache.shiro.cache.Cache; //導入方法依賴的package包/類
/**
 * If possible, this method caches the authorization info for an API key by its ID.  This may be called
 * either by an explicit call to get the authorization info by ID or as a side effect of loading the
 * authorization info by API key and proactive caching by ID.
 */
private void cacheAuthorizationInfoById(String id, AuthorizationInfo authorizationInfo) {
    Cache<String, AuthorizationInfo> idAuthorizationCache = getAvailableIdAuthorizationCache();

    if (idAuthorizationCache != null) {
        idAuthorizationCache.put(id, authorizationInfo);
    }
}
 
開發者ID:bazaarvoice,項目名稱:emodb,代碼行數:13,代碼來源:ApiKeyRealm.java

示例5: cacheAuthenticationInfoIfPossible

import org.apache.shiro.cache.Cache; //導入方法依賴的package包/類
/**
 * Caches the specified info if authentication caching
 * {@link #isAuthenticationCachingEnabled(org.apache.shiro.authc.AuthenticationToken, org.apache.shiro.authc.AuthenticationInfo) isEnabled}
 * for the specific token/info pair and a cache instance is available to be used.
 *
 * @param token the authentication token submitted which resulted in a successful authentication attempt.
 * @param info  the AuthenticationInfo to cache as a result of the successful authentication attempt.
 * @since 1.2
 */
private void cacheAuthenticationInfoIfPossible(AuthenticationToken token, AuthenticationInfo info) {
    if (!isAuthenticationCachingEnabled(token, info)) {
        log.debug("AuthenticationInfo caching is disabled for info [{}].  Submitted token: [{}].", info, token);
        //return quietly, caching is disabled for this token/info pair:
        return;
    }

    Cache<Object, AuthenticationInfo> cache = getAvailableAuthenticationCache();
    if (cache != null) {
        Object key = getAuthenticationCacheKey(token);
        cache.put(key, info);
        log.trace("Cached AuthenticationInfo for continued authentication.  key=[{}], value=[{}].", key, info);
    }
}
 
開發者ID:xuegongzi,項目名稱:rabbitframework,代碼行數:24,代碼來源:AuthenticatingRealm.java

示例6: setCache

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

示例7: updateCache

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


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