jakarta-jcs-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ard Schrijvers" <a.schrijv...@hippo.nl>
Subject question regarding removing a cachekey according the correct eviction policy from the outside
Date Wed, 19 Jul 2006 09:50:34 GMT
Hello,

I have a question regarding removing keys: 

In cocoon we have a JCSDefaultStore implementing org.apache.excalibur.store.Store interface.
This interface has a method free(). store.free() (store can be the EHDefaultStore (ehcache)
or the JCSDefaultStore, etc etc) is invoked by org.apache.excalibur.store.impl.StoreJanitorImpl
when the JVM is low on memory. 

Free() tries to remove cachekeys+response to free some memory. For example, the JCSDefaultStore
does it like below:

public void free() {
        // TODO Find a better way
        MemoryCache memoryCache = this.cacheManager.getCache(region).getMemoryCache();
        Object[] keys = memoryCache.getKeyArray();
        if ( keys != null && keys.length > 0 ) {
            final Object key = keys[0];
            try {
                memoryCache.remove((Serializable)key);
            } catch (Exception ignore) {                
            }
        }
}

The TODO speaks for itself. The EHDefaultStore using ehcache has this very same problem. Just
removing cachekeys starting at index 0 does not improve the JVM when requests keep coming
in, and the mainly important keys have been removed. 

I was told that from the outside, it is impossible to remove keys from the ehcache according
the correct eviction policy. Does this also hold for JCS? And, furthermore, perhaps I just
want to overflow the cached responses to disk (without having reached maxobjects) instead
of removing them. That would clear memory and let me keep the cached responses. 

Is there something possible like, 

public void remove(int numberKeys) and
public void overflow(int numberKeys) 

and that this is done according the correct eviction policy? 

Regards Ard

-- 

Hippo
Oosteinde 11
1017WT Amsterdam
The Netherlands
Tel  +31 (0)20 5224466
-------------------------------------------------------------
a.schrijvers@hippo.nl / http://www.hippo.nl
-------------------------------------------------------------- 

---------------------------------------------------------------------
To unsubscribe, e-mail: jcs-users-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jcs-users-help@jakarta.apache.org


Mime
View raw message