日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 >

java ehcahce刷新_Spring整合ehcache 注解实现查询缓存,并实现实时缓存更新或删除...

發(fā)布時(shí)間:2024/2/28 40 豆豆
生活随笔 收集整理的這篇文章主要介紹了 java ehcahce刷新_Spring整合ehcache 注解实现查询缓存,并实现实时缓存更新或删除... 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

寫在前面:上一篇博客寫了spring cache和ehcache的基本介紹,個(gè)人建議先把這些最基本的知識(shí)了解了才能對(duì)今天主題有所感觸。不多說了,開干!

注:引入jar

net.sf.ehcache

ehcache

2.8.3

第一步:首先配置ehcache.xml

xsi:noNamespaceSchemaLocation="ehcache.xsd"

updateCheck="true" monitoring="autodetect"

dynamicConfig="true">

maxEntriesLocalHeap="10000"

eternal="false"

overflowToDisk="false"

timeToIdleSeconds="120"

timeToLiveSeconds="120"

diskSpoolBufferSizeMB="30"

maxEntriesLocalDisk="10000000"

diskExpiryThreadIntervalSeconds="120"

memoryStoreEvictionPolicy="LRU">

maxEntriesLocalHeap="10000"

maxEntriesLocalDisk="1000"

eternal="false"

diskSpoolBufferSizeMB="30"

timeToIdleSeconds="300"

timeToLiveSeconds="600"

memoryStoreEvictionPolicy="LFU"

transactionalMode="off">

第二步:在spring.xml的配置文件中引入schema,

xmlns:aop="http://www.springframework.org/schema/aop"和http://www.springframework.org/schema/cache? http://www.springframework.org/schema/cache/spring-cache-3.2.xsd

緩存的配置:

OK!緩存的相關(guān)配置已經(jīng)完成。下面開始編寫測(cè)試程序。這里需要連接數(shù)據(jù)庫,我就不寫了。這里為了方便就隨便找了之前寫過的model,這個(gè)model就是AOP注解實(shí)現(xiàn)日志管理的實(shí)體,為了偷懶就直接用了,希望你們不要誤解,沒有特殊意義的

第三步:編寫model,這里需要注意,要實(shí)現(xiàn)緩存的實(shí)體必須要序列化 private static final long serialVersionUID = -6579533328390250520L;? 關(guān)于序列化的生成這里就不介紹了,大家可以百度看看。

package org.shop.entity;

import java.io.Serializable;

import java.util.Date;

public class SystemLog implements Serializable {

private static final long serialVersionUID = -6579533328390250520L;

private String id;

private String description;

private String method;

private Long logType;

private String requestIp;

private String exceptioncode;

private String exceptionDetail;

private String params;

private String createBy;

private Date createDate;

public String getId() {

return id;

}

public void setId(String id) {

this.id = id == null ? null : id.trim();

}

public String getDescription() {

return description;

}

public void setDescription(String description) {

this.description = description == null ? null : description.trim();

}

public String getMethod() {

return method;

}

public void setMethod(String method) {

this.method = method == null ? null : method.trim();

}

public Long getLogType() {

return logType;

}

public void setLogType(Long logType) {

this.logType = logType;

}

public String getRequestIp() {

return requestIp;

}

public void setRequestIp(String requestIp) {

this.requestIp = requestIp == null ? null : requestIp.trim();

}

public String getExceptioncode() {

return exceptioncode;

}

public void setExceptioncode(String exceptioncode) {

this.exceptioncode = exceptioncode == null ? null : exceptioncode.trim();

}

public String getExceptionDetail() {

return exceptionDetail;

}

public void setExceptionDetail(String exceptionDetail) {

this.exceptionDetail = exceptionDetail == null ? null : exceptionDetail.trim();

}

public String getParams() {

return params;

}

public void setParams(String params) {

this.params = params == null ? null : params.trim();

}

public String getCreateBy() {

return createBy;

}

public void setCreateBy(String createBy) {

this.createBy = createBy == null ? null : createBy.trim();

}

public Date getCreateDate() {

return createDate;

}

public void setCreateDate(Date createDate) {

this.createDate = createDate;

}

}

第四步:編寫dao,service

package org.shop.dao;

import org.shop.entity.SystemLog;

public interface SystemLogMapper {

int deleteByPrimaryKey(String id);

int insert(SystemLog record);

int insertSelective(SystemLog record);

SystemLog selectByPrimaryKey(String id);

int updateByPrimaryKeySelective(SystemLog record);

int updateByPrimaryKey(SystemLog record);

int count();

}

public interface SystemLogService {

int deleteSystemLog(String id);

int insert(SystemLog record);

int insertTest(SystemLog record);

SystemLog findSystemLog(String id);

int updateSystemLog(SystemLog record);

int count();

}

總結(jié)

以上是生活随笔為你收集整理的java ehcahce刷新_Spring整合ehcache 注解实现查询缓存,并实现实时缓存更新或删除...的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。