JiveJdon Community Forums
在线248人   首页   主题总表   培训咨询   精华   查搜   注册    登陆
首页 » 论坛 » 项目工程开发经验谈
???en_US.forumThreadPrev.name??? 上一主题
  Go back to the topic 返回本主题   Go back to the topic listing返回主题列表
???en_US.forumThreadNext.name??? 下一主题
Go 总共有 14 回复 / 1
 发表新帖子   回复该主题贴
python

悄悄话
发表文章: 6
注册时间: 2006年01月12日 16:42
项目中用到OSCache来实现jsp页面缓存功能的杂谈 2006年01月12日 17:04 到本帖网址 加入本帖到收藏夹 发送到手机 回复该主题
标签列表 缓存(86)     
本人是一新手,项目中用到OSCache来实现jsp页面缓存功能,自己大概总结了一下,有不足之处,请大家别见笑!
1.jsp页面中定义。
<%@ taglib uri="oscache" prefix="cache" %>
<cache:cache key="关键字" time="300" scope="application">
...要缓存的部分...
</cache:cache>
2.web.xml中定义。
<taglib>
<taglib-uri>oscache</taglib-uri>
<taglib-location>/WEB-INF/classes/oscache.tld</taglib-location>
</taglib>
3.oscache.tld
......
<name>cache</name>
<tag-class>com.opensymphony.oscache.web.tag.CacheTag</tag-class>
<body-content>JSP</body-content>
........
4.用的是oscache-2.1.jar
放在你的应用服务器lib\目录下或你的应用程序\WEB-INF\lib\下
注意的地方:
cache的地方,session就不能用了。
搜索页面部分不要用cache,每个人搜索的内容都不一样的。
关键子的定义,每个页面的关键子当然都不一样的,另外如果有分页,得把分页参数取得,放入关键字里,(不然的话,每页内容都一样了),如果还有其他的传入参数,比如查看不同分类,会有不同分类的ID,也要放到关键字里。
执行一次JSP,而后在设定的时间内,客户端访问的都是HTML页面。

小弟是一新手,大家见笑了!
python

悄悄话
发表文章: 6
注册时间: 2006年01月12日 16:42
Re: 项目中用到OSCache来实现jsp页面缓存功能的杂谈 2006年01月12日 17:09 到本帖网址 加入本帖到收藏夹 发送到手机 回复该主题
1.jsp页面中定义。
《%@ taglib uri="oscache" prefix="cache" %》
《cache:cache key="关键字" time="300" scope="application"》
...要缓存的部分...
《/cache:cache》
2.web.xml中定义。
《taglib》
《taglib-uri》oscache《/taglib-uri》
《taglib-location》/WEB-INF/classes/oscache.tld《/taglib-location》
《/taglib》
3.oscache.tld
......
《name》cache《/nam》
《tag-class》com.opensymphony.oscache.web.tag.CacheTag《/tag-class》
《body-content》JSP《/body-content》
........
banq

悄悄话
发表文章: 9312
注册时间: 2002年08月03日 17:08
Re: 项目中用到OSCache来实现jsp页面缓存功能的杂谈 2006年01月12日 17:13 到本帖网址 加入本帖到收藏夹 发送到手机 回复该主题
非常不错,贴代码时,选择上方的Code即可。
在web.xml中,配置OScache拦截时,好像只能是*.jsp,如果是*就出错。
python

悄悄话
发表文章: 6
注册时间: 2006年01月12日 16:42
Re: 项目中用到OSCache来实现jsp页面缓存功能的杂谈 2006年01月12日 17:17 到本帖网址 加入本帖到收藏夹 发送到手机 回复该主题
好兴奋,感谢斑竹的肯定,以后我会把工作中的经验发到这里,和大家一起分享!大家共同进步!
cute

悄悄话
发表文章: 247
注册时间: 2002年09月26日 11:14
Re: 项目中用到OSCache来实现jsp页面缓存功能的杂谈 2006年01月13日 14:24 到本帖网址 加入本帖到收藏夹 发送到手机 回复该主题
我在一个门户网站中就全面用到了OSCACHE缓存系统,我感觉还是不错的。

搂住说的功能,是实现内存缓存方式。另外一种就是磁盘缓存,可以在OSCACHE配置文件中,指定磁盘物理目录,系统运行后,就会把缓存的页面,全部以文件形式存储在目录中。后者一般是针对内存不足以够的情况下使用。

缓存的数据每30分钟自动刷新数据,这是默认的。可以在WEB。XML中指定刷新时间,也可以手工刷新。


另外,OSCache还支持集群功能.



磁盘缓存实现:

oscache.properties

# cache IN MEMORY
#
# If you want to disable memory caching, just uncomment this line.
#
cache.memory=false


# cache KEY
#
# This is the key that will be used to store the cache in the application
# and session scope.
#
# If you want to set the cache key to anything other than the default
# uncomment this line and change the cache.key
#
# cache.key=__oscache_cache


# USE HOST DOMAIN NAME IN KEY
#
# Servers for multiple host domains may wish to add host name info to
# the generation of the key. If this is true, then uncomment the
# following line.
#
# cache.use.host.domain.in.key=true


# cache LISTENERS
#
# These hook OSCache events and perform various actions such as logging
# cache hits and misses, or broadcasting to other cache instances across a cluster.
# See the documentation for further information.
#
# cache.event.listeners=com.opensymphony.oscache.plugins.clustersupport.JMSBroadcastingListener, \
# com.opensymphony.oscache.extra.CacheEntryEventListenerImpl, \
# com.opensymphony.oscache.extra.CacheMapAccessEventListenerImpl, \
# com.opensymphony.oscache.extra.ScopeEventListenerImpl


# cache PERSISTENCE CLASS
#
# Specify the class to use for persistence. If you use the supplied DiskPersistenceListener,
# don't forget to supply the cache.path property to specify the location of the cache
# directory.
#
# If a persistence class is not specified, OSCache will use memory caching only.
#
#cache.persistence.class=com.opensymphony.oscache.plugins.diskpersistence.HashDiskPersistenceListener
cache.persistence.class=com.opensymphony.oscache.plugins.diskpersistence.HashDiskPersistenceListener
# cache OVERFLOW PERSISTENCE
# Use persistent cache in overflow or not. The default value is false, which means
# the persistent cache will be used at all times for every entry. true is the recommended setting.
#
#cache.persistence.overflow.only=false

# cache DIRECTORY
#
# This is the directory on disk where caches will be stored by the DiskPersistenceListener.
# it will be created if it doesn't already exist. Remember that OSCache must have
# write permission to this directory.
#
# Note: for Windows machines, this needs \ to be escaped
# ie Windows:
# cache.path=c:\\myapp\\cache
# or *ix:
# cache.path=/opt/myapp/cache
#
cache.path=F:\\jboss-3.2.1\\server\\default\\deploy\\weihai.war\\powercache


# cache ALGORITHM
#
# Default cache algorithm to use. Note that in order to use an algorithm
# the cache size must also be specified. If the cache size is not specified,
# the cache algorithm will be Unlimited cache.
#
cache.algorithm=com.opensymphony.oscache.base.algorithm.LRUCache
# cache.algorithm=com.opensymphony.oscache.base.algorithm.FIFOCache
# cache.algorithm=com.opensymphony.oscache.base.algorithm.UnlimitedCache

# THREAD BLOCKING BEHAVIOR
#
# When a request is made for a stale cache entry, it is possible that another thread is already
# in the process of rebuilding that entry. This setting specifies how OSCache handles the
# subsequent 'non-building' threads. The default behaviour (cache.blocking=false) is to serve
# the old content to subsequent threads until the cache entry has been updated. This provides
# the best performance (at the cost of serving slightly stale data). When blocking is enabled,
# threads will instead block until the new cache entry is ready to be served. Once the new entry
# is put in the cache the blocked threads will be restarted and given the new entry.
# Note that even if blocking is disabled, when there is no stale data available to be served
# threads will block until the data is added to the cache by the thread that is responsible
# for building the data.
cache.blocking=true


# cache SIZE
#
# Default cache size in number of items. If a size is specified but not
# an algorithm, the cache algorithm used will be LRUCache.
cache.capacity=4000



# cache UNLIMITED DISK ??????????????????1000??????????1000???LRU?????????????????
# Use unlimited disk cache or not. The default value is false, which means
# the disk cache will be limited in size to the value specified by cache.capacity.
cache.unlimited.disk=true



# JMS CLUSTER PROPERTIES
#
# Configuration properties for JMS clustering. See the clustering documentation
# for more information on these settings.
#
#cache.cluster.jms.topic.factory=java:comp/env/jms/TopicConnectionFactory
#cache.cluster.jms.topic.name=java:comp/env/jms/OSCacheTopic
#cache.cluster.jms.node.name=node1


# JAVAGROUPS CLUSTER PROPERTIES
#
# Configuration properites for the JavaGroups clustering. Only one of these
# should be specified. Default values (as shown below) will be used if niether
# property is set. See the clustering documentation and the JavaGroups project
# (www.javagroups.com) for more information on these settings.
#
#cache.cluster.properties=UDP(mcast_addr=231.12.21.132;mcast_port=45566;ip_ttl=32;\
#mcast_send_buf_size=150000;mcast_recv_buf_size=80000):\
#PING(timeout=2000;num_initial_members=3):\
#MERGE2(min_interval=5000;max_interval=10000):\
#FD_SOCK:VERIFY_SUSPECT(timeout=1500):\
#pbcast.NAKACK(gc_lag=50;retransmit_timeout=300,600,1200,2400,4800;max_xmit_size=8192):\
#UNICAST(timeout=300,600,1200,2400):\
#pbcast.STABLE(desired_avg_gossip=20000):\
#FRAG(frag_size=8096;down_thread=false;up_thread=false):\
#pbcast.GMS(join_timeout=5000;join_retry_timeout=2000;shun=false;print_local_addr=true)
#cache.cluster.multicast.ip=231.12.21.132
cute

悄悄话
发表文章: 247
注册时间: 2002年09月26日 11:14
Re: 项目中用到OSCache来实现jsp页面缓存功能的杂谈 2006年01月13日 14:27 到本帖网址 加入本帖到收藏夹 发送到手机 回复该主题
如果企业有钱的话,就不推荐使用OSCache....
他们可以去买网站内容管理,这样就可以生成静态页面了.

.OSCache无非就是减轻服务器压力....




ttzx8888

悄悄话
发表文章: 3
注册时间: 2006年02月03日 01:28
Re: 项目中用到OSCache来实现jsp页面缓存功能的杂谈 2006年02月03日 01:39 到本帖网址 加入本帖到收藏夹 发送到手机 回复该主题
请问 OSCACHE 中 缓存的作用范围
APPLICATION SESSION
到底该怎么选择 是什么意思
zrweng

悄悄话
发表文章: 20
注册时间: 2003年03月17日 15:12
Re: 项目中用到OSCache词迪jsp页面缓存功能的杂谈 2006年02月03日 11:19 到本帖网址 加入本帖到收藏夹 发送到手机 回复该主题
> 请问 OSCACHE 中 缓存的作用范围
> APPLICATION SESSION
> 到底该怎么选择 是什么意思

这样看情况了,如果是Portal系统,大多数页面对于大多数人来说是一样的,那么使用Application,如果是MIS系统,将涉及数据权限,用JSP缓存的意义并不大,一般是采用对象缓存.
ttzx8888

悄悄话
发表文章: 3
注册时间: 2006年02月03日 01:28
Re: 项目中用到OSCache词迪jsp页面缓存功能的杂谈 2006年02月03日 12:23 到本帖网址 加入本帖到收藏夹 发送到手机 回复该主题
再请问下
OSCACHE对 JSP部分内容的缓存

<cache:cache>
<%
//自己的JSP代码内容
%>
</cache:cache>

在<cache:cache> </cache:cache>标签之间是否可包含其他的标签
比如Struts
ttzx8888

悄悄话
发表文章: 3
注册时间: 2006年02月03日 01:28
Re: 项目中用到OSCache词迪jsp页面缓存功能的杂谈 2006年02月03日 12:25 到本帖网址 加入本帖到收藏夹 发送到手机 回复该主题
再请问下
OSCACHE对 JSP部分内容的缓存



<cache:cache key="foobar" scope="session">
<%
//自己的JSP代码内容
%>
</cache:cache>



在<cache:cache></cache:cache> 标签之间是否可包含其他的标签
比如Struts
conjee

悄悄话
发表文章: 1
注册时间: 2004年05月14日 17:39
Re: 项目中用到OSCache来实现jsp页面缓存功能的杂谈 2006年03月08日 09:26 到本帖网址 加入本帖到收藏夹 发送到手机 回复该主题
如果我的应用是采用Struts模式,几乎所有的JSP都是通过.do的方式跳转,那么用OSCACHE是否有效,我考虑在ACTION里来cache,但是研究了一天,对一般对象可以,但是如果是采用类的反射机制取得的LIST,putincache和getfromcache的值是空,不知道什么原因,大家可以研究一下
bigdogyang

悄悄话
发表文章: 1
注册时间: 2005年07月09日 23:30
Re: 项目中用到OSCache来实现jsp页面缓存功能的杂谈 2006年03月23日 11:49 到本帖网址 加入本帖到收藏夹 发送到手机 回复该主题
小弟现在做一个项目,想用OS cache做业务层的部分数据的缓存,不知道用OS cache能不能做,具体的思路是什么样的,麻烦高人指点一二。
xyxx

悄悄话
发表文章: 16
注册时间: 2006年01月17日 10:26
Re: 项目中用到OSCache来实现jsp页面缓存功能的杂谈 2006年03月23日 17:52 到本帖网址 加入本帖到收藏夹 发送到手机 回复该主题
从功能来讲,oscache是个可用的缓存
从性能来讲,oscache缓存的性能很差
sim114

悄悄话
发表文章: 19
注册时间: 2002年12月19日 11:48
Re: 项目中用到OSCache来实现jsp页面缓存功能的杂谈 2006年03月24日 12:16 到本帖网址 加入本帖到收藏夹 发送到手机 回复该主题


从性能来讲,oscache缓存的性能很差


性能很差?那方面?
sim114

悄悄话
发表文章: 19
注册时间: 2002年12月19日 11:48
Re: 项目中用到OSCache来实现jsp页面缓存功能的杂谈 2006年03月24日 13:18 到本帖网址 加入本帖到收藏夹 发送到手机 回复该主题
内存使用太大? 命中率太低?

这个主题有 14 回复 / 1Go
???en_US.forumThreadPrev.name??? 上一主题
  Go back to the topic 返回本主题   Go back to the topic listing返回主题列表    返回页首返回页首
???en_US.forumThreadNext.name??? 下一主题
热点TAG: AOP cache 缓存 DDD EJB 集群 设计模式 Hibernate IOC JiveJdon OO RBAC Seam Spring Struts
正在读取,请等待...
google yahoo 新浪ViVi 365Key网摘 天极网摘 CSDN网摘 添加到百度搜藏 POCO网摘 博采网摘
查询本论坛内 回复超过的热门帖子
     回复该主题贴
标题
 
粗体 斜体 下划线 插入图片 插入代码 插入url链接 插入附件
内容
 

手机阅读 add to google add to yahoo
解惑之道在J道 ,打造中国最具影响力的的企业软件社区
OpenSource JIVEJDON v3.0 Powered by JdonFramework Code © 2002-08 jdon.com
anti spam