程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> JAVA編程 >> 關於JAVA >> osCache 配置說明

osCache 配置說明

編輯:關於JAVA

osCache 配置說明

作者: [email protected] (MSN)

E文地址:http://wiki.opensymphony.com/display/CACHE/Configuration

這個東西今天小試了一下,總體感覺還不錯.就不知道比起JBoss cache 有沒什麼差別(現在本人還不得而知啊)

主要是針對 osCache 的配置文件做了簡單的翻譯; 如有錯誤敬請修正.修改的文檔請共享一下,謝謝!

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 illegal

filesystem 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);

 

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved