There is one option which is close to what you need.
When you specify passivation == off and eviction == on, the cache store will be basically a superset of the cache. Every time you store someting in the cache, the cache entry will go also to the cache store. Furthermore, when eviction is enabled and you reached maxEntries, some of the entries (according to the strategy in use) will be removed from the cache but not from the cache store (don't get it confused with expiration).
Later, when you call get() for an entry that is only in the cache store, it will be loaded into the memory but won't be removed from the cache store.
Martin: I tested that configuration (passivation=false and envition enabled with maxEntries specified), and found the evition removes the cache entries from both the cache and cache store. Maybe my cinfiguration is not right?
<namedCache name="keychain" >
<async useReplQueue="true" replQueueInterval="500" replQueueMaxElements="100" asyncMarshalling="false" />
<transaction transactionMode="TRANSACTIONAL" />
<property name="stringsTableNamePrefix" value="ISPN_STRING_TABLE"/>
<property name="idColumnName" value="ID_COLUMN"/>
<property name="dataColumnName" value="DATA_COLUMN"/>
<property name="timestampColumnName" value="TIMESTAMP_COLUMN"/>
<property name="timestampColumnType" value="BIGINT"/>
<property name="datasourceJndiLocation" value="java:comp/env/jdbc/UserProfileDB"/>
<property name="idColumnType" value="VARCHAR(255)"/>
<property name="dataColumnType" value="BLOB"/>
<property name="dropTableOnExit" value="false"/>
<property name="createTableOnStart" value="true"/>
<async enabled="true" flushLockTimeout="15000" shutdownTimeout="30000" modificationQueueSize="1000" threadPoolSize="100"/>
your configuration seems to be correct. However, I'm pretty sure this is working, or at least it was working a short time ago. Could you please file a JIRA and attach a TRACE log? If it is not working, it's most likely a bug.
Also there are some tests that should prove it really works. Like this one: https://infinispan.ci.cloudbees.com/job/Infinispan-5.1.x-JDK6-tcp/195/org.infinispan$infinispan-core/testReport/org.infinispan.eviction/EvictionWithPassivationTest/
Okay, I'll try it again and let you know the results.
I tried some simple tests. The eviction works as expected, i.e., eviction removes entries only from the memory not the store. The only minor issue is that the actual max entries in memory is quite off to the maxEntries I speciped. That's what I am looking for. Thanks.
the maxEntries parameter should be a power of 2 (2,4,8,16,...), when you set a number which is not a power of 2, it will be rounded to the closess higher number which is power of two. However, you will rarely see exactly that number of entries in the cache. The rule is that the number of entries in the cache must not be higher than maxEntries, usually it will be lower than that.
Martn, thanks for the info on maxEntries.