Java Code Examples for org.apache.shiro.cache.Cache#put()

The following examples show how to use org.apache.shiro.cache.Cache#put() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ApiKeyRealm.java    From emodb with Apache License 2.0 6 votes vote down vote up
/**
 * 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();
}
 
Example 2
Source File: CacheDelegator.java    From jsets-shiro-spring-boot-starter with Apache License 2.0 5 votes vote down vote up
/**
 * 获取并增加密码重试次数
 */
public int incPasswdRetryCount(String account) {
	Cache<String, Integer> cache = this.cacheManager.getCache(ShiroProperties.CACHE_NAME_PASSWORD_RETRY);
	synchronized (cacheMonitor) {
		Integer count = cache.get(account);
		if (null == count) {
			count = new Integer(0);
		}
		cache.put(account, ++count);
		return count;
	}
}
 
Example 3
Source File: CacheDelegator.java    From jsets-shiro-spring-boot-starter with Apache License 2.0 5 votes vote down vote up
/**
 * 销毁token
 * <>
 * 如果tokean是销毁过的,返回true
 */
public boolean burnedToken(String token) {
	Cache<String, Integer> cache = this.cacheManager.getCache(ShiroProperties.CACHE_NAME_TOKEN_BURNERS);
	Integer burned = cache.get(token);
	if (null == burned) {
		cache.put(token, Integer.valueOf(0));
		return false;
	}
	return true;
}
 
Example 4
Source File: EHCacheManager.java    From mumu with Apache License 2.0 5 votes vote down vote up
/**
 * 存入缓存
 * @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);
}
 
Example 5
Source File: ApiKeyRealm.java    From emodb with Apache License 2.0 5 votes vote down vote up
/**
 * 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);
    }
}
 
Example 6
Source File: MemCacheUtil.java    From MultimediaDesktop with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example 7
Source File: CacheDelegator.java    From jsets-shiro-spring-boot-starter with Apache License 2.0 4 votes vote down vote up
/**
 * 缓存保持登陆状态的用户
 */
public String putKeepUser(String account, String sessionId) {
	Cache<String, String> cache = this.cacheManager.getCache(ShiroProperties.CACHE_NAME_KEEP_ONE_USER);
	return cache.put(account, sessionId);
}