当前位置: 首页>>代码示例>>Java>>正文


Java Caching类代码示例

本文整理汇总了Java中org.springframework.cache.annotation.Caching的典型用法代码示例。如果您正苦于以下问题:Java Caching类的具体用法?Java Caching怎么用?Java Caching使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Caching类属于org.springframework.cache.annotation包,在下文中一共展示了Caching类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createDownloadUsage

import org.springframework.cache.annotation.Caching; //导入依赖的package包/类
/**
 * Saves persistently a download performed by a user.
 *
 * @param size       download size.
 * @param start_date date downloading start.
 * @param user       associate user to download.
 */
@Transactional
@Caching (evict = {
   @CacheEvict (value = "network_download_count", key = "#user.getUUID ()", condition = "#user != null"),
   @CacheEvict (value = "network_download_size", key = "#user.getUUID ()", condition = "#user != null") })
public void createDownloadUsage (final Long size, final Date start_date,
      final User user)
{
   if (size == null || size < 0 || start_date == null || user == null)
   {
      throw new IllegalArgumentException ("Invalid parameters");
   }

   NetworkUsage download_usage = new NetworkUsage ();
   download_usage.setSize (size);
   download_usage.setDate (start_date);
   download_usage.setUser (user);
   download_usage.setIsDownload (true);
   networkUsageDao.create (download_usage);
}
 
开发者ID:SentinelDataHub,项目名称:dhus-core,代码行数:27,代码来源:NetworkUsageService.java

示例2: resetPassword

import org.springframework.cache.annotation.Caching; //导入依赖的package包/类
@Transactional (readOnly=false, propagation=Propagation.REQUIRED)
@Caching (evict = {
   @CacheEvict(value = "user", allEntries = true),
   @CacheEvict(value = "userByName", allEntries = true)})
public void resetPassword(String code, String new_password)
   throws RootNotModifiableException, RequiredFieldMissingException, 
      EmailNotSentException
{
   User u = userDao.getUserFromUserCode (code);
   if (u == null)
   {
      throw new UserNotExistingException ();
   }
   checkRoot (u);

   u.setPassword (new_password);

   checkRequiredFields (u);
   userDao.update (u);
}
 
开发者ID:SentinelDataHub,项目名称:dhus-core,代码行数:21,代码来源:UserService.java

示例3: selfUpdateUser

import org.springframework.cache.annotation.Caching; //导入依赖的package包/类
/**
 * Update given User, after checking required fields.
 * 
 * @param user
 * @throws RootNotModifiableException
 * @throws RequiredFieldMissingException
 */
@PreAuthorize ("isAuthenticated ()")
@Transactional (readOnly=false, propagation=Propagation.REQUIRED)
@Caching (evict = {
   @CacheEvict(value = "user", key = "#user.getUUID ()"),
   @CacheEvict(value = "userByName", key = "#user.username.toLowerCase()")})
public void selfUpdateUser (User user) throws RootNotModifiableException,
   RequiredFieldMissingException, EmailNotSentException
{
   User u = userDao.read (user.getUUID ());
   checkRoot (u);
   u.setEmail (user.getEmail ());
   u.setFirstname (user.getFirstname ());
   u.setLastname (user.getLastname ());
   u.setAddress (user.getAddress ());
   u.setPhone (user.getPhone ());    
   u.setCountry (user.getCountry ());
   u.setUsage (user.getUsage ());
   u.setSubUsage (user.getSubUsage ());
   u.setDomain (user.getDomain ());
   u.setSubDomain (user.getSubDomain ());  

   checkRequiredFields (u);
   userDao.update (u);
}
 
开发者ID:SentinelDataHub,项目名称:dhus-core,代码行数:32,代码来源:UserService.java

示例4: insertOneArticle

import org.springframework.cache.annotation.Caching; //导入依赖的package包/类
@Override
@Transactional(rollbackFor = Exception.class)
@Caching(evict = {
        @CacheEvict(value = "getOneArticleById", key =  "#root.target.oneArticleKey + #article.id"),
        @CacheEvict(value = "getArticlesCount", key = "#root.target.articleCountKey + #username")
})
public long insertOneArticle(Article article) {
    long articleId = idWorker.nextId();
    article.setId(articleId);
    article.setCreatedTime(new Date());  // add the created time
    article.setModifiedTime(new Date());  // add the modified time

    articleMapper.insertOneArticle(article);

    logger.info(article.getUsername() + " insert article " + article.getId() + " successfully");

    deleteAllPagesCache(article.getUsername());

    return articleId;
}
 
开发者ID:ziwenxie,项目名称:leafer,代码行数:21,代码来源:ArticleServiceImpl.java

示例5: deletePost

import org.springframework.cache.annotation.Caching; //导入依赖的package包/类
@Caching(evict = {
    @CacheEvict(value = CACHE_POST, key = "#post.id.toString()"),
    @CacheEvict(value = CACHE_COUNT_USER_TAG_POSTS, key = "#post.user.id.toString().concat('_tags_posts_count')", allEntries = true),
    @CacheEvict(value = TagService.CACHE_COUNT_USER, key = "#post.user.id.toString().concat('_posts_count')")
})
@Transactional
public void deletePost(Post post) {
    PostStatus status = post.getStatus();
    postRepository.delete(post.getId());

    if (status == PostStatus.PUBLIC) {
        Set<Tag> tags = tagRepository.findPostTags(post.getId());
        hotPostService.removeHotPost(post);
        hotPostService.removeTaggedPost(post, tags);
        newPostsService.remove(post.getId());
        newPostsService.removeTaggedPost(post.getId(), tags);
        countingService.decPublicPostsCount();
        tags.forEach(tagService::decreasePostCountByOne); // 标签文章统计需要减一
    }

    PostSearchService.deleteIndex(post.getId());
    countingService.decPostsCount();
}
 
开发者ID:ugouku,项目名称:shoucang,代码行数:24,代码来源:PostService.java

示例6: delete

import org.springframework.cache.annotation.Caching; //导入依赖的package包/类
@Override
@Caching(
		evict = {
				@CacheEvict(key="#object.id"),
				@CacheEvict(cacheResolver="secondaryCacheResolver", allEntries=true)
			}
		)
public T delete(T object) throws DataAccessException {
	if (logger.isDebugEnabled())
		logger.debug("type {} delete", type);
	try {
		mongoOperations.remove(object);
		return object;
	} catch (Exception e) {
		throw new DataAccessException(e);
	}

}
 
开发者ID:quebic-source,项目名称:microservices-sample-project,代码行数:19,代码来源:GenericDaoImpl.java

示例7: deletePermissions

import org.springframework.cache.annotation.Caching; //导入依赖的package包/类
@SuppressWarnings("rawtypes")
@Caching(evict = { @CacheEvict(value = "entornsUsuariActual", allEntries=true), @CacheEvict(value = "consultaCache", allEntries=true)})
public void deletePermissions(
		String recipient,
		boolean principal,
		Set<Permission> permissions,
		Serializable id,
		Class clazz,
		boolean granting) {
	for (Permission permission: permissions) {
		if (principal) {
			aclServiceDao.revocarPermisUsuari(
					recipient,
					clazz,
					(Long)id,
					permission);
		} else {
			aclServiceDao.revocarPermisRol(
					recipient,
					clazz,
					(Long)id,
					permission);
		}
	}
}
 
开发者ID:GovernIB,项目名称:helium,代码行数:26,代码来源:PermissionService.java

示例8: insert

import org.springframework.cache.annotation.Caching; //导入依赖的package包/类
@Override
@Caching(evict = {
        @CacheEvict(key = "'id:'+#result"),
        @CacheEvict(key = "'auth:persion-id'+#result"),
        @CacheEvict(key = "'auth-bind'+#result"),
        @CacheEvict(key = "'person-name'+#authBindEntity.name")
})
public String insert(PersonAuthBindEntity authBindEntity) {
    authBindEntity.setStatus(DataStatus.STATUS_ENABLED);
    if (authBindEntity.getPersonUser() != null) {
        syncUserInfo(authBindEntity);
    }
    String id = this.insert(((PersonEntity) authBindEntity));
    if (authBindEntity.getPositionIds() != null) {
        syncPositionInfo(id, authBindEntity.getPositionIds());
    }
    return id;
}
 
开发者ID:hs-web,项目名称:hsweb-framework,代码行数:19,代码来源:SimplePersonService.java

示例9: updateByPk

import org.springframework.cache.annotation.Caching; //导入依赖的package包/类
@Override
@Caching(evict = {
        @CacheEvict(key = "'id:'+#authBindEntity.id"),
        @CacheEvict(key = "'auth:persion-id'+#authBindEntity.id"),
        @CacheEvict(key = "'auth-bind'+#authBindEntity.id"),
        @CacheEvict(key = "'person-name'+#authBindEntity.name")
})
public int updateByPk(PersonAuthBindEntity authBindEntity) {
    if (authBindEntity.getPositionIds() != null) {
        personPositionDao.deleteByPersonId(authBindEntity.getId());
        syncPositionInfo(authBindEntity.getId(), authBindEntity.getPositionIds());
    }
    if (authBindEntity.getPersonUser() != null) {
        syncUserInfo(authBindEntity);
    }
    return this.updateByPk(((PersonEntity) authBindEntity));
}
 
开发者ID:hs-web,项目名称:hsweb-framework,代码行数:18,代码来源:SimplePersonService.java

示例10: insert

import org.springframework.cache.annotation.Caching; //导入依赖的package包/类
@Override
@Caching(
        put = @CachePut(cacheNames = "oauth2-user-token", key = "'a-t:'+#tokenInfo.accessToken"),
        evict = @CacheEvict(cacheNames = "oauth2-user-token-list", key = "'s-g-t:'+#result.serverId+':'+#result.grantType")
)
@Transactional(propagation = Propagation.NOT_SUPPORTED)
public AccessTokenInfo insert(AccessTokenInfo tokenInfo) {
    if (tokenInfo.getId() == null) {
        tokenInfo.setId(getIDGenerator().generate());
    }
    OAuth2UserTokenEntity entity = entityTokenInfoMapping().apply(tokenInfo);
    entity.setCreateTime(tokenInfo.getCreateTime());
    entity.setUpdateTime(tokenInfo.getUpdateTime());

    insert(entity);
    return tokenInfo;
}
 
开发者ID:hs-web,项目名称:hsweb-framework,代码行数:18,代码来源:SimpleOAuth2UserTokenService.java

示例11: findByMemberId

import org.springframework.cache.annotation.Caching; //导入依赖的package包/类
@Caching(cacheable = {@Cacheable(value = "member", key = "\"Member.memberId:\" + #member.memberId")},
    put = {
        @CachePut(value = "member", key = "\"Member.memberName:\" + #result.memberName",
            condition = "#result != null"),
        @CachePut(value = "member", key = "\"Member.email:\" + #result.email", condition = "#result != null")})
// 将 memberName,email 作为 key 加入到缓存,以便于 findByMemberName,findByEmail 可以使用缓存
public Member findByMemberId(final Member member) {
  System.out.println("cache miss, invoke find by memberId, memberId:" + member.getMemberId());
  for (Member item : members) {
    if (item.getMemberId().equals(member.getMemberId())) {
      return item;
    }
  }

  return null;
}
 
开发者ID:nickevin,项目名称:Qihua,代码行数:17,代码来源:MemberCacheService.java

示例12: updateUser

import org.springframework.cache.annotation.Caching; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
@Caching(evict = { @CacheEvict(value = "users", allEntries = true) }, put = {
        @CachePut(value = "user", key = "#id") })
public User updateUser(User user, String id) throws SecuredAppException {
    User persistedUser = getUserById(id);
    if (persistedUser == null) {
        throw new SecuredAppException("User " + user.getId() + " doesn't exist");
    }

    // List<Role> updatedRoles = new ArrayList<>();
    List<Role> updatedRoles = user.getRoleList().stream().parallel()
            .filter(role -> role.getId() != null)
            .map(role -> getRoleById(role.getId()))
            .collect(Collectors.toCollection(ArrayList::new));
    /*
     * if(roles != null){ for (Role role : roles) { if(role.getId() != null)
     * { updatedRoles.add(getRoleById(role.getId())); } } }
     */
    persistedUser.setRoleList(updatedRoles);
    return userRepository.save(persistedUser);
}
 
开发者ID:rajadilipkolli,项目名称:springsecuredthymeleafapp,代码行数:23,代码来源:SecurityServiceImpl.java

示例13: update

import org.springframework.cache.annotation.Caching; //导入依赖的package包/类
@Caching(evict = {
        @CacheEvict(value = CACHES_NAME, allEntries = true),
        @CacheEvict(value = CACHE_NAME, key = "#one.id")
})
public Tag update(Tag one, TagForm tagForm) {
    Category category = categoryService.findOne(tagForm.getCategoryId());
    if (category == null) {
        return null;
    }

    one.setCode(tagForm.getCode());
    one.setTitle(tagForm.getTitle());
    one.setCategory(category);
    tagRepository.save(one);
    return one;
}
 
开发者ID:microacup,项目名称:microbbs,代码行数:17,代码来源:TagService.java

示例14: flushAllCaches

import org.springframework.cache.annotation.Caching; //导入依赖的package包/类
@Override
@Caching(evict = {
        @CacheEvict(value = SDK_CACHE, allEntries = true),
        @CacheEvict(value = FILE_CACHE, allEntries = true)
})
public void flushAllCaches() throws SandboxServiceException {
    final AdminClient client = clientProvider.getClient();
    client.login(tenantDeveloperUser, tenantDeveloperPassword);
    try {
        retryRestCall(new RestCall() {
            @Override
            public void executeRestCall() throws Exception {
                client.flushSdkCache();
            }
        }, 3, 5000, HttpStatus.UNAUTHORIZED);
    } catch (Exception e) {
        throw Utils.handleException(e);
    }
    LOG.info("All caches have been completely flushed.");
}
 
开发者ID:kaaproject,项目名称:sandbox-frame,代码行数:21,代码来源:CacheServiceImpl.java

示例15: systemDeleteProduct

import org.springframework.cache.annotation.Caching; //导入依赖的package包/类
@Transactional (readOnly=false, propagation=Propagation.REQUIRED)
@IncrementCache (name = "product_count", key = "all", value = -1)
@Caching(evict = {
   @CacheEvict (value = "indexes", key = "#pid"),
   @CacheEvict (value = "product", key = "#pid"),
   @CacheEvict (value = "products", allEntries = true)})
public void systemDeleteProduct (Long pid)
{
   Product product = productDao.read (pid);

   if (product == null)
   {
      throw new DataStoreException ("Product #" + pid +
         " not found in the system.");
   }

   systemDeleteProduct (product, Destination.TRASH);
}
 
开发者ID:SentinelDataHub,项目名称:DataHubSystem,代码行数:19,代码来源:ProductService.java


注:本文中的org.springframework.cache.annotation.Caching类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。