`
shuai1234
  • 浏览: 971998 次
  • 性别: Icon_minigender_1
  • 来自: 山西
社区版块
存档分类
最新评论

OSCache配置参数说明

    博客分类:
  • java
 
阅读更多

oscache.properties  osCache的配置文件,放在 webapp/WEB-INF/classes/下;
oscache.properties 中的配置项如下:

1、cache.memory
原文:

   Valid values are true or false, with true being the default value. If you want to disable memory caching,just comment out or remove this line.
   Note: disabling memory AND disk caching is possible but fairly stupid

译文:
   是否使用内存缓存; true 或 false。默认为true;
   个人推荐内存方法,在速度会有些优势;

2、cache.capacity
原文:
   The maximum number of items that a cache will hold. By default the capacity is unlimited - the cache will never remove any items.Negative values will also be treated as meaning unlimited capacity.

译文:
   缓存的最大数量。默认是不限制,cache不会移走任何缓存内容。负数被视不限制。

3、cache.algorithm
原文:
   The 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 regardless of the value of this property. If you specify a size but not an algorithm, the cache algorithm used will be com.opensymphony.oscache.base.algorithm.LRUCache.
OSCache currently comes with three algorithms:
   * com.opensymphony.oscache.base.algorithm.LRUCache - Least Recently Used.
        This is the default when a cache.capacity is set.
   * com.opensymphony.oscache.base.algorithm.FIFOCache - First In First Out.
   * com.opensymphony.oscache.base.algorithm.UnlimitedCache - Content that is added to the cache will never be discarded.
   This is the default when no value is set for the cache.capacity property.

译文:
   运算规则。为了使用规则,cache的size必须是指定的。
   如果cache的size不指定的话, 将不会限制缓存对象的大小。如果指定了cache的size,但不指定algorithm,
   那它会默认使用:com.opensymphony.oscache.base.algorithm.LRUCache
   有下面三种规则:
   * com.opensymphony.oscache.base.algorithm.LRUCache       : last in first out(最后插入的最先调用)。默认选项。
   * com.opensymphony.oscache.base.algorithm.FIFOCache      : first int first out(最先插入的最先调用)。
   * com.opensymphony.oscache.base.algorithm.UnlimitedCache : cache中的内容将永远不会被丢弃。
   如果cache.capacity不指定值的话,它将被设为默认选项。

4、cache.blocking
原文:
   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.

译文:
   是否同步。true 或者 false。一般设为true,避免读取脏数据。

5。cache.unlimited.disk
原文:
   Indicates whether the disk cache should be treated as unlimited or not. The default value is false.In this case, the disk cache capacity will be equal to the memory cache capacity set by cache.capacity.

译文:
   指定硬盘缓存是否要作限制。默认值为false。false的状况下,disk cache capacity 和cache.capacity的值相同。

6、cache.persistence.class
原文:
   Specifies the class to use for persisting cache entries. This class must implement the PersistenceListener interface.
   OSCache comes with an implementation that provides filesystem based persistence.
Set this property to com.opensymphony.oscache.plugins.diskpersistence.HashDiskPersistenceListener to enable this implementation.By specifying your own class here you should be able to persist cache data using say JDBC or LDAP.
   NOTE: This class hashes the toString() of the object being cached to produce the file name of the entry.If you prefer readable file names, the parent DiskPersistenceListener can still be used but it will have issues with illegalfilesystem characters or long names.The HashDiskPersistenceListener and DiskPersistenceListener classes require cache.path to be set in order to know where to persist the files to disk.

译文:
   指定类是被持久化缓存的类。class必须实现PersistenceListener接口。作为硬盘持久,可以实现com.opensymphony.oscache.plugins.diskpersistence.HashDiskPersistenceListener接口。
它把class的toString()输出的hash值作为文件的名称。如果你要想文件名易读些(自己设定),DiskPersistenceListener 的父类也能使用,但其可能有非法字符或者过长的名字。

注意:
   HashDiskPersistenceListener 和 DiskPersistenceListener 需要设定硬盘路径:cache.path

7、cache.path
原文:
   This specifies the directory on disk where the caches will be stored. The directory will be created if it doesn't already exist,
   but remember that OSCache must have permission to write to this location. Avoid sharing the same cache path between different caches, because OSCache has not been designed to handle this.
   Note:For Windows machines, the backslash character '\' needs to be escaped. ie in Windows:
      cache.path=c:\\myapp\\cache
   or *ix:
      cache.path=/opt/myapp/cache

译文:
   指定硬盘缓存的路径。目录如果不存在将被建立。同时注意oscache应该要有权限写文件系统。
   例:
     cache.path=c:\\myapp\\cache
   or *ix:
     cache.path=/opt/myapp/cache

8、cache.persistence.overflow.only (NEW! Since 2.1)
原文:
   Indicates whether the persistence should only happen once the memory cache capacity has been reached.
   The default value is false for backwards compatibility but the recommended value is true when the memory cache is enabled.
   This property drastically changes the behavior of the cache in that the persisted cache will now be different then what is in memory.

译文:
   指定是否只有在内存不足的情况下才使用硬盘缓存。
   默认值false。但推荐是true如果内存cache被允许的话。这个属性彻底的改变了cache的行为,使得persisted cache和memory是完全不同。

9、cache.event.listeners

    原文:

       This takes a comma-delimited list of fully-qualified class names. Each class in the list must implement one (or more) of

       the following interfaces:

           * CacheEntryEventListener - Receives cache add/update/flush and remove events.

           * CacheMapAccessEventListener - Receives cache access events. This allows you to keep statistical information to track

             how effectively the cache is working.

       No listeners are configured by default, however some ship with OSCache that you may wish to enable:

           * com.opensymphony.oscache.plugins.clustersupport.BroadcastingCacheEventListener - provides clustering support for OSCache.

             Enabling this will cause cache flush events to be broadcast to other instances of OSCache running on your LAN.

             See Clustering OSCache for further information about this event listener.

           * com.opensymphony.oscache.extra.CacheEntryEventListenerImpl - a simple listener implementation that maintains a running

             count of all of the entry events that occur during a cache's lifetime.

           * com.opensymphony.oscache.extra.CacheMapAccessEventListenerImpl - a simple listener implementation that keeps count of

             all the cache map events (cache hits and misses, and stale hits) that occur on a cache instance.

    译文:

       class名列表(用逗号隔开)。每个class必须实现以下接口中的一个 或者几个

       CacheEntryEventListener:接收cache add/update/flush and remove事件

       CacheMapAccessEventListener :接收cache访问事件。这个可以让你跟踪cache怎么工作。

      

       默认是不配置任何class的。当然你可以使用一下的class:

           * com.opensymphony.oscache.plugins.clustersupport.BroadcastingCacheEventListener : 分布式的监听器。可以广播到局域网内的其他cache实例。

            * com.opensymphony.oscache.extra.CacheEntryEventListenerImpl :一个简单的监听器。在cache的生命周期中记录所有entry的事件。

            * com.opensymphony.oscache.extra.CacheMapAccessEventListenerImpl : 记录count of cache map events(cache hits,misses and state hits).

10、cache.key

    原文:

       This is the key that will be used by the ServletCacheAdministrator

       (and hence the custom tags) to store the cache object in the application and session scope.

       The default value when this property is not specified is "__oscache_cache". If you want to access this default value in your code,

       it is available as com.opensymphony.oscache.base.Const.DEFAULT_CACHE_KEY.

    译文:

        在application 和 session的作用域时 用于标识cache 对象的,  用于ServletCacheAdministrator;

        此属性不是指定为"__oscache_cache"格式时为默认值, 如果代码中需要用到默认值时可以通使用com.opensymphony.oscache.base.Const.DEFAULT_CACHE_KEY

       来取得;

11、cache.use.host.domain.in.key

    原文:

        If your server is configured with multiple hosts, you may wish to add host name information to automatically generated

       cache keys. If so, set this property to true. The default value is false.

    译文:

        当配置多个服务器时,想通过服备器名称自动生成cache key时,可将此属性设为true. 默认值为false;

       

12、Additional Properties

    原文:

        In additon to the above basic options, any other properties that are specified in this file will still be loaded and can be

       made available to your event handlers. For example, the JavaGroupsBroadcastingListener supports the following additional

       properties:

    译文:

        在以上基础选项之上可以加入一些额外的属性到此文件中.

       例:  JavaGroupsBroadcastingListener 便是额外的.

13、cache.cluster.multicast.ip

    原文:

        The multicast IP to use for this cache cluster. Defaults to 231.12.21.132.

    译文:

        用于缓存集群. 默认为231.12.21.132

14、cache.cluster.properties

    原文:

        Specifies additional configuration options for the clustering. The default setting is

       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)

  

    译文:

        指集群中的额外配置项. 以下是默认设置:(此属性的相关说将在集群文档中说明)

       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)

原文:

    See the Clustering OSCache documentation for further details on the above two properties.

译文:

   以上两项的详细信息可以看 OSCache集群文档(http://wiki.opensymphony.com/display/CACHE/Clustering);

分享到:
评论

相关推荐

    OSCache配置说明文档

    5.2.2 CacheFilter参数说明 CacheFilter的配置涉及多个参数,例如`cacheName`用于指定缓存区域,`cacheKey`定义了缓存键的生成规则,`cacheTimeToLive`设置缓存存活时间等。 5.3 局部缓存 局部缓存则是在特定的业务...

    oscache说明

    3. 根据你的应用需求,配置 `oscache.properties` 文件以设置缓存参数。 **使用方法** OSCache 提供了多种使用方式: 1. **缓存对象**:可以直接调用 OSCache 的 API 接口来缓存和检索对象。API 包括了缓存的存取...

    OSCache使用说明

    3. 将 oscache.properties 文件放入应用的 src 根目录或 /WEB-INF/classes 目录,以便于配置缓存参数。 4. 如果需要集群缓存,需要添加 jgroups.jar 到类路径中。 5. 在 log4j.properties 中配置日志级别,如设置 ...

    oscache-2.4.1-full.rar

    网上对于OSCache缓存Web页面很多说明和例子,但对于缓存对象方面说得不多,我就把自已写得一些东西放出来,让大家看一看是怎样缓存对象的! 我基于GeneralCacheAdministrator类来写的BaseCache类 view plaincopy...

    Spring+Struts2+iBatis简要说明

    Spring通过`applicationContext.xml`配置文件来配置应用上下文,这里可以定义Bean、事务管理、连接池等。Spring还提供了与iBatis的集成,使得事务管理和DAO层的数据库操作得以统一管理。 Struts2是MVC模式的具体...

    新美大MySQL数据一致性探索.pdf

    接下来,文档中提到了一些具体的数据库参数和配置项,例如“innodb_flush_log_at_trx_commit”、“bufferpool”、“logbuffer”、“oscache”、“sync_binlog=1”等。这些参数的设置对MySQL数据库的事务日志记录和...

    iBATIS缓存介绍

    - **3.5.3 OSCACHE基本使用及配置项说明** - OSCACHE利用操作系统的缓存机制,提供更高的性能。 - 配置项包括缓存的大小、刷新间隔等。 #### 四、参考资料 由于篇幅限制,具体的参考资料未给出,建议查阅官方...

    SSH 中jar包说明

    - **用途**:Java Bean Validation API为JavaBean属性和方法参数的验证提供了一套统一的标准。 - **作用**:提供了一致的数据验证机制,简化了输入校验的过程。 #### 17. **javassist-3.9.0.GA.jar** - **用途**:...

    hibernate 3.2.6架包(包括所有jar,eg,api)

    这些文档通常包含方法描述、参数说明和使用示例,是学习和使用Hibernate的重要资源。 6. 配置与集成:Hibernate 3.2.6可以通过XML配置文件(hibernate.cfg.xml)进行设置,包括数据库连接信息、缓存策略、实体类...

    最全面的门户网站架构设计方案.doc

    2) WEB应用服务器性能 a) CPU b) 存储,I/O访问 c) 内存 d) 并发TCP/IP连接数 3) 数据库服务器性能 a) 数据库参数配置 b) 服务器性能(CPU、内存、存储) c) 数据结构的合理性 4) 不同WEB应用的处理方式而对不同的...

Global site tag (gtag.js) - Google Analytics