本文整理匯總了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();
}
示例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();
}
示例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);
}
示例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);
}
}
示例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);
}
}
示例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);
}
示例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);
}
}