---
title: "oscache使用步骤"
author: "jinxinwei"
date: "2015-07-27T07:39:06Z"
tags: ["Cache"]
categories: ["Web前端"]
slug: "oscache"
draft: false
lastmod: "2015-07-26T19:11:45Z"
id: 2230360
url: "https://jinxinwei.iteye.com/blog/2230360"
---

1：导入相关的jar包； 2：在classpath路径中放入oscache.properties文件： 配置项有： 缓存模式false为硬盘，true为内存 cache.memory=false ##缓存到硬盘的持久化类 cache.persistence.class=com.opensymphony.oscache.plugins.diskpersistence.DiskPersistenceListener ##硬盘模式缓存路径 cache.path=D:\\\\oscache ##缓存个数 cache.capacity=1000 3：缓存为全局缓存时配置过滤器，该过滤器放在过滤器最前面 CacheFilter com.opensymphony.oscache.web.filter.CacheFilter time 600 scope session|application CacheFilter (要缓存的url路径)/product/list/* 4：局部缓存是用法 导入标签库：&lt;%@ taglib uri="http://www.opensymphony.com/oscache" prefix="oscache" %&gt; 要局部缓存的地方加入： &lt;% //自己的JSP代码内容 %&gt; 5：刷新缓存 //清除application范围内的缓存 //清除指定key的缓存 //清除组名为currentData，范围application的缓存 缓存是以Map的形式存储的，key为网页的访问url,或者也可以自定义，例如 缓存的数据分两种范围:application(所有人都可以获取),session(只有用户可以获取自己的)