缓存技术(OScache)

来源:互联网 发布:java服务器集群搭建 编辑:程序博客网 时间:2024/05/04 18:25

默认缓存在内存 要保存在硬盘需修改 oscache.properties文件

1.1.导入相关包

commons-logging.jar
jgroups-all.jar
oscache-2.4.1.jar

1.2.将这个文件(oscache.properties)导入到src目录下

修改保存的位置路径

cache.capacity=1000
cache.memory=false
cache.path=d:\\oscache
cache.persistence.class=com.opensymphony.oscache.plugins.diskpersistence.DiskPersistenceListener


2.新建一个jsp页面 

<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8" import="java.util.*"%>

<!--新导入的 -->
<%@ taglib prefix="oscache" uri="http://www.opensymphony.com/oscache"%>


<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
当前时间:<%=new Date()%><br />

<oscache:cache>
缓存时间:<%=new Date()%>
</oscache:cache>
</body>
</html>

0 0