Return-Path: Delivered-To: apmail-jakarta-jcs-users-archive@www.apache.org Received: (qmail 65825 invoked from network); 20 Jul 2006 20:09:24 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 20 Jul 2006 20:09:24 -0000 Received: (qmail 35929 invoked by uid 500); 20 Jul 2006 19:38:34 -0000 Delivered-To: apmail-jakarta-jcs-users-archive@jakarta.apache.org Received: (qmail 35901 invoked by uid 500); 20 Jul 2006 19:38:34 -0000 Mailing-List: contact jcs-users-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "JCS Users List" Delivered-To: mailing list jcs-users@jakarta.apache.org Received: (qmail 35845 invoked by uid 99); 20 Jul 2006 19:38:34 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 20 Jul 2006 12:38:34 -0700 X-ASF-Spam-Status: No, hits=2.8 required=10.0 tests=DNS_FROM_RFC_ABUSE,DNS_FROM_RFC_POST,DNS_FROM_RFC_WHOIS X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [209.191.125.90] (HELO web38714.mail.mud.yahoo.com) (209.191.125.90) by apache.org (qpsmtpd/0.29) with SMTP; Thu, 20 Jul 2006 12:38:32 -0700 Received: (qmail 3155 invoked by uid 60001); 20 Jul 2006 19:38:11 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=Message-ID:Received:Date:From:Subject:To:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=k45dm/yIwRxf6U+x5V2RWzMfEDLZa8OljRWgAoke44/b5AMHaFrQQgPzU1W5xUniVaNAlgMp2QGQ74me/fxoA638v6qWIrIUOSpXnP1G5tnpTpxooeGi9FLeY6H6npSoI7IVd2g2v/2za93KiVy1C3WLhy74Gtxciu3k6d4Nz0k= ; Message-ID: <20060720193811.3153.qmail@web38714.mail.mud.yahoo.com> Received: from [151.193.220.27] by web38714.mail.mud.yahoo.com via HTTP; Thu, 20 Jul 2006 12:38:11 PDT Date: Thu, 20 Jul 2006 12:38:11 -0700 (PDT) From: Aaron Smuts Subject: RE: question regarding removing a cachekey according the correct eviction policy from the outside To: JCS Users List In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N We can add a free( int numberToFree ) method to the memory cache interface. The expected behavior will be that that any memory cache should delete the items that would be next to go given its eviction policy. This should do the trick. The LRUMemoryCache will just spool the "numberToFree" least recently used items. You'll still have to get the memory cache from the composite cache, since this method is not general enough for all types of cache auxiliaries. We could put it in the JCS convenience class as well, so you wouldn't have to deal with JCS at such a low level. Aaron --- Ard Schrijvers wrote: > > > JCS is completely pluggable, unlike eh*%$^. > Hence, > > you can provide your own memory cache. An easy > way to > > do this would be to extend the LRUMemoryCache and > > provide the logic that you need. > > > > Since JCS is jdk1.3 compliant, I have not created > any > > memory size related methods. I will eventually > put in > > a memory cache that will balk if some percentage > of > > total memory is consumed. Alternatively, you > could > > spool the last item whenever some configurable > > percentage of memory has ben reached. > > That does not matter for us, because in cocoon, the > StoreJanitor takes care of actual memory consumed, > and acts when necessary. All it does, is estimate > the number of keys to be removed (memoryStoreKeys, > not diskStoreKeys), and remove these. So, in a loop > for example the free() method of the JCSDefaultStore > is called. But this free() method removes keys > starting from index 0. Do you think that extending > the LRUMemoryCache would give me the possibility to > remove keys according the correct eviction policy? > > > > > Also, I'm working on a configuration option that > will > > allow you to put all items to disk and not just > those > > that are spooled. > > You mean I can manually spool a number X cached > responses to disk according the correct eviction > policy without being at maxObjects in memoryStore? > > Regards Ard > > > > > Aaron > > > > > > > > --- Ard Schrijvers wrote: > > > > > 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 > > > > > > > > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: > jcs-users-unsubscribe@jakarta.apache.org > > For additional commands, e-mail: > jcs-users-help@jakarta.apache.org > > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: > jcs-users-unsubscribe@jakarta.apache.org > For additional commands, e-mail: > jcs-users-help@jakarta.apache.org > > --------------------------------------------------------------------- To unsubscribe, e-mail: jcs-users-unsubscribe@jakarta.apache.org For additional commands, e-mail: jcs-users-help@jakarta.apache.org