ehcache
来源:互联网 发布:常用协议端口号 编辑:程序博客网 时间:2024/06/06 15:49
net.sf.ehcache ehcache2.7.5 bean.xml(spring配置文件)中加入 com.googlecode.ehcache-spring-annotations ehcache-spring-annotations1.2.0 创建ehcache.xml package com.hyq.console.publish.service.impl;import java.util.HashMap;import java.util.List;import javax.annotation.Resource;import org.springframework.cache.annotation.CacheEvict;import org.springframework.cache.annotation.Cacheable;import org.springframework.stereotype.Service;import com.hyq.common.hyqobject.HyqPageParam;import com.hyq.console.publish.entity.Article;import com.hyq.console.publish.mapper.ArticleMapper;import com.hyq.console.publish.service.ArticleService;/** * * @author 515848218@qq.com * */@Servicepublic class ArticleServiceImpl implements ArticleService {@Resource(name = "articleMapper")private ArticleMapper articleMapper;@Override@CacheEvict(value="springEhcache", key="'getlist'+#article.getItemId()")public boolean addArticle(Article article) {try {int i = articleMapper.insertSelective(article);if (i > 0) {return true;}} catch (Exception e) {e.printStackTrace();}return false;}@Override@CacheEvict(value="springEhcache", key="'getlist'+#article.getItemId()")public boolean updateArticle(Article article) {try {int i = articleMapper.updateByPrimaryKeySelective(article);if (i > 0) {return true;}} catch (Exception e) {e.printStackTrace();}return false;}@Override@CacheEvict(value="springEhcache", key="'getlist'+#article.getItemId()")public void delete(Article article) throws Exception {if (article != null) {articleMapper.deleteByPrimaryKey(article.getId());}}@Overridepublic Article getArticle(Integer articleId) {return articleMapper.selectByPrimaryKey(articleId);}@Override@Cacheable(value="springEhcache", key="'getlist'+#hpp.getKeywordb()")public List getList(HyqPageParam hpp) {System.out.println("=================================非缓存==============================");return articleMapper.getList(hpp);}@Overridepublic int getTotal(HyqPageParam hpp) {return articleMapper.getTotal(hpp);}@Override@Cacheable(value="springEhcache", key="'getlist'+#itemId")public List getListByItemId(Integer itemId, Integer nums) {HashMap hm = new HashMap ();hm.put("itemId", itemId);hm.put("nums", nums);return articleMapper.getListByItemId(hm);}}
0 0
- Ehcache
- Ehcache
- ehcache
- ehcache
- EHCache
- ehCache
- ehcache
- ehcache
- ehcache
- ehcache
- ehcache
- ehcache
- EhCache
- Ehcache
- ehcache
- Ehcache
- ehcache
- EHCache
- 多维高斯分布模型
- HDU4738【边双连通分量】
- 字符数组
- 抽象类和接口——Java
- 调停者模式(Mediator)
- ehcache
- Unity3d搭建HTTP弱联网的服务器搭建及客户端编写(二)之php服务器
- Unity用Lua开发的 使用度 问题
- oracle删除添加表空间
- 函数——Python学习笔记03
- hdoj 2586
- POJ3177【边双连通分量缩点】
- 有关Canvas图像覆盖问题
- 为什么用接口存常量是一种不良的习惯