我正在嘗試爲僅在短時間內相關的數據創建一個jboss緩存。在那段時間之後,數據應該被丟棄並且相應的存儲空間被釋放。如何避免JBoss-Cache區域被驅逐?
緩存組織這樣的:
/my_region
/session_1
/datanode_1
attribute1: value1
/datanode_2
attribute2: value2
/session_2
...
/session_3
...
...
...
而且我驅逐策略的配置是這樣的:
<attribute name="EvictionPolicyClass">org.jboss.cache.eviction.LRUPolicy</attribute>
<attribute name="EvictionPolicyConfig">
<config>
<attribute name="wakeUpIntervalSeconds">5</attribute>
<region name="/my_region">
<attribute name="maxNodes">100</attribute>
<attribute name="timeToLiveSeconds">1800</attribute>
</region>
</config>
</attribute>
這工作:當/my_region
獲得超過100個孩子,最近最少使用兒童被驅逐,使該地區縮減回100個孩子。
與LRUPolicy
的問題是,當被驅逐的節點有子女時,they're not completely removed, but marked with jboss:internal:uninitialized: null
instead。這種行爲對於被緩存的實體來說是有意義的,以避免從持久存儲中獲取它們,但是它不適合緩存沒有被保存並且將不會再被訪問的實體。
因此,要刪除節點,我創建了一個擴展名爲LRUPolicy
的文件,該文件覆蓋了帶有remove的evict。
@Override
public void evict(Fqn fqn) throws Exception {
cache_.remove(fqn);
}
這一新政策不會留下joss:internal:uninitialized: null
的背後,卻是達到maxNodes
時刪除/my_region
節點。當我把LRUPolicy
放回去時,我注意到區域節點本身實際上被驅逐並獲得了unitialized
標籤,但是最近使用的100個孩子仍然存在。
如何防止該地區本身被驅逐?有沒有更好的方式去除而不拆除eviction from expiration?
我正在使用jboss緩存版本1.3.0.SP4。
什麼版本的jboss緩存? – skaffman 2010-02-18 21:35:45
1.3.0.SP4,我會將它包含在問題中。 – hvrauhal 2010-02-19 07:46:55