You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Upayavira <uv...@upaya.co.uk> on 2003/08/10 18:47:36 UTC

Switching cache to Persistent Store

[Resending - didn't realise my mailer was sending HTML rather than text]

I've been exploring how to get the CLI to use Cocoon's caching mechanism and  
environment.isLastModified() to prevent the CLI from generating otherwise cached  
pages. 

The problem I currently have is that the cache Cocoon uses is transient, and is  
thus lost every time the CLI restarts.  

So: 
a) How can I switch Cocoon to always use a Persistent cache? Putting  
<cache><parameter name="store"  
value="org.apache.excalibur.store.Store"/></cache> into cocoon.xconf makes  
CacheImpl pick a persistent store, but for some reason values aren't in the store  
after Cocoon has been restarted. 
b) How can I get Cocoon to use a persisitent store for CLI and a transient one for  
servlet? 

To show the sort of impovements possible, here's two pages, each generated  
twice, the second time cached. For those interested in improving the performance  
of the CLI, check out the benefits :-) 

* docs/index.html [4.447 seconds] 
* docs/index.html [0.3 seconds] 
* samples/hello-world/hello.html [0.381 seconds] 
* samples/hello-world/hello.html [0.04 seconds] 
Total time: 0 minutes 14 seconds 

Regards, 

Upayavira 

Re: Switching cache to Persistent Store

Posted by Sylvain Wallez <sy...@anyware-tech.com>.
Upayavira wrote:

>On 11 Aug 2003 at 8:49, Geoff Howard wrote:
>
>  
>
>>Joerg Heinicke wrote:
>>    
>>
>>>IIRC it's a Jetty /feature/. Tomcat does not do this.
>>>
>>>Joerg
>>>
>>>      
>>>
>>>>I've just done a further check which makes this problem easier to
>>>>see: 1) add the <cache><parameter name="store"
>>>>value="org.apache.excalibur.store.Store"/> </cache> thing to
>>>>cocoon.xconf. 2) Start Cocoon in Jetty 3) Load a page to get
>>>>something into the cache, e.g:
>>>>http://localhost:8888/samples/hello-world/ 4) Go to
>>>>http://localhost:8888/samples/status.html and you'll see your pages
>>>>in the default store. Correct. 5) Shut down Jetty and restart 6) Go
>>>>back to http://localhost:8888/samples/status.html and you're pages
>>>>have disappeared from the default store. Surely this is wrong!
>>>>
>>>>Regards, Upayavira
>>>>        
>>>>
>>Yes, I found this when working on the event-based caching.  Jetty
>>apparently deletes (or at least does not reuse) its work directory.
>>This would also cause XSP's to be recompiled after startup.  Anyone
>>know Jetty enough to figure out how to re-configure this?
>>    
>>
>
>But the same thing is happening with the CLI. It isn't deleting its work directory, but it 
>certainly isn't reusing it. Any ideas what I can do about it? Might it be the same thing 
>affecting the CLI and Jetty?
>  
>

An idea : the MRUMemoryStore swaps its content to disk either when some 
memory limit is reached, either on dispose(). Does the CocoonBean call 
dispose() on Cocoon ?

Sylvain

-- 
Sylvain Wallez                                  Anyware Technologies
http://www.apache.org/~sylvain           http://www.anyware-tech.com
{ XML, Java, Cocoon, OpenSource }*{ Training, Consulting, Projects }
Orixo, the opensource XML business alliance  -  http://www.orixo.com



Re: Switching cache to Persistent Store

Posted by Upayavira <uv...@upaya.co.uk>.
On 11 Aug 2003 at 8:49, Geoff Howard wrote:

> Joerg Heinicke wrote:
> > IIRC it's a Jetty /feature/. Tomcat does not do this.
> > 
> > Joerg
> > 
> >> I've just done a further check which makes this problem easier to
> >> see: 1) add the <cache><parameter name="store"
> >> value="org.apache.excalibur.store.Store"/> </cache> thing to
> >> cocoon.xconf. 2) Start Cocoon in Jetty 3) Load a page to get
> >> something into the cache, e.g:
> >> http://localhost:8888/samples/hello-world/ 4) Go to
> >> http://localhost:8888/samples/status.html and you'll see your pages
> >> in the default store. Correct. 5) Shut down Jetty and restart 6) Go
> >> back to http://localhost:8888/samples/status.html and you're pages
> >> have disappeared from the default store. Surely this is wrong!
> >>
> >> Regards, Upayavira
> 
> Yes, I found this when working on the event-based caching.  Jetty
> apparently deletes (or at least does not reuse) its work directory.
> This would also cause XSP's to be recompiled after startup.  Anyone
> know Jetty enough to figure out how to re-configure this?

But the same thing is happening with the CLI. It isn't deleting its work directory, but it 
certainly isn't reusing it. Any ideas what I can do about it? Might it be the same thing 
affecting the CLI and Jetty?

Regards, Upayavira


Re: Switching cache to Persistent Store

Posted by Vadim Gritsenko <va...@verizon.net>.
Upayavira wrote:

> ...
>  
>
>>Vadim's already answered you on that but another point is that I'm
>>pretty sure there's nothing wrong with the Store(s) or Cache because I
>>don't see this happening in the webapp.  You could prove this to
>>yourself by configuring the max-objects param for transient-store in
>>cocoon.xconf to a very small number (like 5) and then watching items
>>go into the persistent storage by using the webapp some.  You can then
>>use the sample to clear the MRU store and you'll see that you can
>>still get cached responses out of the persistent-store.
>>    
>>
>
>I haven't tried all that yet, but I have just got my webapp working via Tomcat rather 
>than Jetty and:
>* load a sample page
>* load status page - contains stuff in MRUMemoryStore
>* restart Tomcat and wait
>* reload status page - MRU and Default stores are both empty
>
>I'm happy that things might make it into the persistent store during the life of a 
>particular invocation of the servlet container. What I'm complaining about is that the 
>persistent store doesn't seem to survive a restart of the servlet container/Cocoon.
>

There was a bug in DefaultStore.java. Should be fixed now; try again. 
Same bug was present in excalibur-store too.

Vadim



Re: Switching cache to Persistent Store

Posted by Upayavira <uv...@upaya.co.uk>.
 ...
> 
> Vadim's already answered you on that but another point is that I'm
> pretty sure there's nothing wrong with the Store(s) or Cache because I
> don't see this happening in the webapp.  You could prove this to
> yourself by configuring the max-objects param for transient-store in
> cocoon.xconf to a very small number (like 5) and then watching items
> go into the persistent storage by using the webapp some.  You can then
> use the sample to clear the MRU store and you'll see that you can
> still get cached responses out of the persistent-store.

I haven't tried all that yet, but I have just got my webapp working via Tomcat rather 
than Jetty and:
* load a sample page
* load status page - contains stuff in MRUMemoryStore
* restart Tomcat and wait
* reload status page - MRU and Default stores are both empty

I'm happy that things might make it into the persistent store during the life of a 
particular invocation of the servlet container. What I'm complaining about is that the 
persistent store doesn't seem to survive a restart of the servlet container/Cocoon. 

Regards, Upayavira


Re: Switching cache to Persistent Store

Posted by Geoff Howard <co...@leverageweb.com>.
Upayavira wrote:
> Geoff,
> 

>>  - No cache element is needed in cocoon.xconf because it's defined in
>>  cocoon.roles (and if you just removed the event-cache by deleting the
>>  xconf entry you probably didn't really remove it) - The cache role is
>>  a wrapper around transient-store and persistent-store which come
>>  predifined in cocoon.xconf
> 
> Okay. All I was doing was switching from transient to persistent, but 
> your explanation below tells me I don't need to do that.
>>  These components work together like this:
>>
>>  Cache wraps transient-store which uses persistent-store (if and only
>>  if *<parameter name="use-persistent-cache" value="true"/> is set on
>>  transient-store in cocoon.xconf which it is by default)
>>
>>  All new items go into the transient-store, and if configured, older
>>  items are moved into persistent-store when they are bumped off the
>>  bottom of the stack, or on container shutdown.  All this happens by
>>  default out of the box and is working correctly (unless you
>>  delete/fail to reuse the cache-dir as Jetty does) for the servlet
>>  mode.
> 
> As far as I can see, I reuse the cache-dir. Or at least, there's a file 
> in the cache-dir that gets updated, and I use the same cache-dir each time.

...

> Anyway, I've done some more research, including downloading the source 
> for Avalon (for the first time!) and stepped through the code for the 
> Store.

...

Vadim's already answered you on that but another point is that I'm 
pretty sure there's nothing wrong with the Store(s) or Cache because I 
don't see this happening in the webapp.  You could prove this to 
yourself by configuring the max-objects param for transient-store in 
cocoon.xconf to a very small number (like 5) and then watching items go 
into the persistent storage by using the webapp some.  You can then use 
the sample to clear the MRU store and you'll see that you can still get 
cached responses out of the persistent-store.

Let me know how that turns out.

Geoff


Re: Switching cache to Persistent Store

Posted by Vadim Gritsenko <va...@verizon.net>.
Upayavira wrote:
...

> Anyway, I've done some more research, including downloading the source 
> for Avalon (for the first time!) and stepped through the code for the 
> Store.
>
> I don't know if this is a problem, but in AbstractJispFilesystemStore, 
> the get and store methods don't seem to match up:
>
> get():
> value = m_Database.read(this.wrapKeyObject(key), m_Index);
>
> and
>
> store():
> KeyObject[] keyArray = new KeyObject[1];
>                 keyArray[0] = this.wrapKeyObject(key);
>                 m_Database.write(keyArray, (Serializable) value);
>
> So one uses a wrapped key object, and the other uses an array of 
> wrapped key objects with one element. Does this mean it's not using 
> the same key, and thus can never get at stuff in the persistent store? 
> Is this correct?


That's Ok.
http://www.coyotegulch.com/docs/jisp/com/coyotegulch/jisp/IndexedObjectDatabase.html


> [I've still to work out how to compile Avalon, so I can't try it 
> myself yet!]


To compile avalon you need maven... Or you can simply put avalon 
framework jar in the place where it should be and simply run "ant" in 
avalon-excalibur/store directory.

Vadim



Re: Switching cache to Persistent Store

Posted by Geoff Howard <co...@leverageweb.com>.
Upayavira wrote:
> On 11 Aug 2003 at 10:43, Geoff Howard wrote:
>>Upayavira wrote:
>>>On 11 Aug 2003 at 16:22, Sylvain Wallez wrote:
>>>>Joerg Heinicke wrote:
>>>>>IIRC it's a Jetty /feature/. Tomcat does not do this.
>>>>
>>>>Yes, because Jetty creates a different temporary directory at each
>>>>run, while Tomcat always uses the same.
>>>
>>>So the solution, for Jetty at least then, is to make the path to the
>>>work directory absolute (in cocoon.xconf), rather than relative to
>>>the context temp dir, which can change.
>>>
>>>But unfortunately that doesn't explain my CLI problem :-(
>>
>>Ah, yes.  I was being dense - you mentioned Jetty (well, :8888) in
>>your example and we went from there.
>>
>>Can you explain again what you're seeing in the CLI - how have you
>>configured the cache/work dir in cli.xconf? (sorry, I'm totally
>>ignorant of CLI workings)  Does this problem go away if you
>>un-configure my event cache?  EventCacheImpl will clear the cache if
>>it is unable to retrieve its serialized state (rare).  Perhaps there
>>is a bug related to CLI with that process?
> 
> I'm seeing the first request taking 4 seconds, and the second for the same page 
> taking 0.4 seconds. Debugging the code, the first store.get() doesn't return anything, 
> but the second does. Restart Cocoon (i.e. rerun the CLI), and you get the same 
> behaviour, store.get() returns nothing first time and returns something second time.

OK...

> It seems to work this way all of the time, regardless of what I do!
> 
> The work dir is configured in the cli.xconf, and is simply created with new 
> File(workDir). The cache directory is made from the work dir with cache-dir 
> appended.

Sorry for my ignorance - I don't see any caching set up in cli.xconf, so 
I assume that means you are inheriting the definitions from 
cocoon.xconf?  That eliminates one class of problems (unless you're not 
using the default cocoon.xconf - if that's the case, send your transient 
and peristent store decl. declaration here

I noticed you have <work-dir>../temp/docs</work-dir>
After a run of the cli is that dir (really the cache dir under it) empty?

> Once I worked out what was going on with your EventCache, I removed it, and it 
> made no difference. 

Whew.

> Removing it enabled me to get it to switch to using a persistent store by putting a 
> <cache> element into cocoon.xconf, but the is persistent store (DefaultStore) doesn't 
> survive a restart of the CLI, either, i.e. the first store.get() returns nothing and the 
> second store.get() does.

Huh?
- No cache element is needed in cocoon.xconf because it's defined in 
cocoon.roles (and if you just removed the event-cache by deleting the 
xconf entry you probably didn't really remove it)
- The cache role is a wrapper around transient-store and 
persistent-store which come predifined in cocoon.xconf

These components work together like this:

Cache wraps transient-store which uses persistent-store (if and only if 
*<parameter name="use-persistent-cache" value="true"/> is set on 
transient-store in cocoon.xconf which it is by default)

All new items go into the transient-store, and if configured, older 
items are moved into persistent-store when they are bumped off the 
bottom of the stack, or on container shutdown.  All this happens by 
default out of the box and is working correctly (unless you delete/fail 
to reuse the cache-dir as Jetty does) for the servlet mode.

Sorry if that is all obvious to you but that last paragraph makes me 
think you've got some things turned around in your head - probably 
because of the Jetty behavior.

Geoff*


Re: Switching cache to Persistent Store

Posted by Upayavira <uv...@upaya.co.uk>.
On 11 Aug 2003 at 10:43, Geoff Howard wrote:

> Upayavira wrote:
> > On 11 Aug 2003 at 16:22, Sylvain Wallez wrote:
> > 
> > 
> >>Joerg Heinicke wrote:
> >>
> >>
> >>>IIRC it's a Jetty /feature/. Tomcat does not do this.
> >>
> >>
> >>Yes, because Jetty creates a different temporary directory at each
> >>run, while Tomcat always uses the same.
> > 
> > 
> > So the solution, for Jetty at least then, is to make the path to the
> > work directory absolute (in cocoon.xconf), rather than relative to
> > the context temp dir, which can change.
> > 
> > But unfortunately that doesn't explain my CLI problem :-(
> > 
> > Regards, Upayavira
> 
> Ah, yes.  I was being dense - you mentioned Jetty (well, :8888) in
> your example and we went from there.
> 
> Can you explain again what you're seeing in the CLI - how have you
> configured the cache/work dir in cli.xconf? (sorry, I'm totally
> ignorant of CLI workings)  Does this problem go away if you
> un-configure my event cache?  EventCacheImpl will clear the cache if
> it is unable to retrieve its serialized state (rare).  Perhaps there
> is a bug related to CLI with that process?

I'm seeing the first request taking 4 seconds, and the second for the same page 
taking 0.4 seconds. Debugging the code, the first store.get() doesn't return anything, 
but the second does. Restart Cocoon (i.e. rerun the CLI), and you get the same 
behaviour, store.get() returns nothing first time and returns something second time.

It seems to work this way all of the time, regardless of what I do!

The work dir is configured in the cli.xconf, and is simply created with new 
File(workDir). The cache directory is made from the work dir with cache-dir 
appended.

Once I worked out what was going on with your EventCache, I removed it, and it 
made no difference. 

Removing it enabled me to get it to switch to using a persistent store by putting a 
<cache> element into cocoon.xconf, but the is persistent store (DefaultStore) doesn't 
survive a restart of the CLI, either, i.e. the first store.get() returns nothing and the 
second store.get() does.

Any ideas here?

Regards, Upayavira


Re: Switching cache to Persistent Store

Posted by Geoff Howard <co...@leverageweb.com>.
Upayavira wrote:
> On 11 Aug 2003 at 16:22, Sylvain Wallez wrote:
> 
> 
>>Joerg Heinicke wrote:
>>
>>
>>>IIRC it's a Jetty /feature/. Tomcat does not do this.
>>
>>
>>Yes, because Jetty creates a different temporary directory at each
>>run, while Tomcat always uses the same.
> 
> 
> So the solution, for Jetty at least then, is to make the path to the work directory 
> absolute (in cocoon.xconf), rather than relative to the context temp dir, which can 
> change.
> 
> But unfortunately that doesn't explain my CLI problem :-(
> 
> Regards, Upayavira

Ah, yes.  I was being dense - you mentioned Jetty (well, :8888) in your 
example and we went from there.

Can you explain again what you're seeing in the CLI - how have you 
configured the cache/work dir in cli.xconf? (sorry, I'm totally ignorant 
of CLI workings)  Does this problem go away if you un-configure my event 
cache?  EventCacheImpl will clear the cache if it is unable to retrieve 
its serialized state (rare).  Perhaps there is a bug related to CLI with 
that process?

Geoff


Re: Switching cache to Persistent Store

Posted by Upayavira <uv...@upaya.co.uk>.
On 11 Aug 2003 at 16:22, Sylvain Wallez wrote:

> Joerg Heinicke wrote:
> 
> > IIRC it's a Jetty /feature/. Tomcat does not do this.
> 
> 
> Yes, because Jetty creates a different temporary directory at each
> run, while Tomcat always uses the same.

So the solution, for Jetty at least then, is to make the path to the work directory 
absolute (in cocoon.xconf), rather than relative to the context temp dir, which can 
change.

But unfortunately that doesn't explain my CLI problem :-(

Regards, Upayavira

> >> I've just done a further check which makes this problem easier to
> >> see: 1) add the <cache><parameter name="store"
> >> value="org.apache.excalibur.store.Store"/> </cache> thing to
> >> cocoon.xconf. 2) Start Cocoon in Jetty 3) Load a page to get
> >> something into the cache, e.g:
> >> http://localhost:8888/samples/hello-world/ 4) Go to
> >> http://localhost:8888/samples/status.html and you'll see your pages
> >> in the default store. Correct. 5) Shut down Jetty and restart 6) Go
> >> back to http://localhost:8888/samples/status.html and you're pages
> >> have disappeared from the default store. Surely this is wrong! 
> >
> 
> Sylvain
> 
> -- 
> Sylvain Wallez                                  Anyware Technologies
> http://www.apache.org/~sylvain           http://www.anyware-tech.com {
> XML, Java, Cocoon, OpenSource }*{ Training, Consulting, Projects }
> Orixo, the opensource XML business alliance  -  http://www.orixo.com
> 
> 



Re: Switching cache to Persistent Store

Posted by Sylvain Wallez <sy...@anyware-tech.com>.
Joerg Heinicke wrote:

> IIRC it's a Jetty /feature/. Tomcat does not do this.


Yes, because Jetty creates a different temporary directory at each run, 
while Tomcat always uses the same.

>> I've just done a further check which makes this problem easier to see:
>> 1) add the <cache><parameter name="store" 
>> value="org.apache.excalibur.store.Store"/> </cache> thing to 
>> cocoon.xconf. 2) Start Cocoon in Jetty
>> 3) Load a page to get something into the cache, e.g: 
>> http://localhost:8888/samples/hello-world/
>> 4) Go to http://localhost:8888/samples/status.html and you'll see 
>> your pages in the default store. Correct.
>> 5) Shut down Jetty and restart
>> 6) Go back to http://localhost:8888/samples/status.html and you're 
>> pages have disappeared from the default store. Surely this is wrong! 
>

Sylvain

-- 
Sylvain Wallez                                  Anyware Technologies
http://www.apache.org/~sylvain           http://www.anyware-tech.com
{ XML, Java, Cocoon, OpenSource }*{ Training, Consulting, Projects }
Orixo, the opensource XML business alliance  -  http://www.orixo.com



Re: Switching cache to Persistent Store

Posted by Geoff Howard <co...@leverageweb.com>.
Joerg Heinicke wrote:
> IIRC it's a Jetty /feature/. Tomcat does not do this.
> 
> Joerg
> 
>> I've just done a further check which makes this problem easier to see:
>> 1) add the <cache><parameter name="store" 
>> value="org.apache.excalibur.store.Store"/> </cache> thing to 
>> cocoon.xconf. 2) Start Cocoon in Jetty
>> 3) Load a page to get something into the cache, e.g: 
>> http://localhost:8888/samples/hello-world/
>> 4) Go to http://localhost:8888/samples/status.html and you'll see your 
>> pages in the default store. Correct.
>> 5) Shut down Jetty and restart
>> 6) Go back to http://localhost:8888/samples/status.html and you're 
>> pages have disappeared from the default store. Surely this is wrong!
>>
>> Regards, Upayavira

Yes, I found this when working on the event-based caching.  Jetty 
apparently deletes (or at least does not reuse) its work directory. 
This would also cause XSP's to be recompiled after startup.  Anyone know 
Jetty enough to figure out how to re-configure this?

Geoff


Re: Switching cache to Persistent Store

Posted by Joerg Heinicke <jo...@gmx.de>.
IIRC it's a Jetty /feature/. Tomcat does not do this.

Joerg

> I've just done a further check which makes this problem easier to see:
> 1) add the <cache><parameter name="store" 
> value="org.apache.excalibur.store.Store"/> </cache> thing to cocoon.xconf. 
> 2) Start Cocoon in Jetty
> 3) Load a page to get something into the cache, e.g: 
> http://localhost:8888/samples/hello-world/
> 4) Go to http://localhost:8888/samples/status.html and you'll see your pages in the 
> default store. Correct.
> 5) Shut down Jetty and restart
> 6) Go back to http://localhost:8888/samples/status.html and you're pages have 
> disappeared from the default store. Surely this is wrong!
> 
> Regards, Upayavira


RE: Switching cache to Persistent Store

Posted by Upayavira <uv...@upaya.co.uk>.
On 11 Aug 2003 at 12:16, Upayavira wrote:

> On 11 Aug 2003 at 12:06, Carsten Ziegeler wrote:
> 
> > Upayavira wrote:
> > > 
> > > I've been exploring how to get the CLI to use Cocoon's caching
> > > mechanism and  environment.isLastModified() to prevent the CLI
> > > from generating otherwise cached  pages. 
> > > 
> > > The problem I currently have is that the cache Cocoon uses is
> > > transient, and is  thus lost every time the CLI restarts.  
> > > 
> > > So: 
> > > a) How can I switch Cocoon to always use a Persistent cache?
> > > Putting
> > >  <cache><parameter name="store" 
> > > value="org.apache.excalibur.store.Store"/></cache> into
> > > cocoon.xconf makes  CacheImpl pick a persistent store, but for
> > > some reason values aren't in the store  after Cocoon has been
> > > restarted. 
> 
> > What do you mean by "after Cocoon has been restarted"? I'm not sure
> > but it could be possible that the store is cleaned on startup.
> 
> All I know is that, when the store is transient, the first page that
> is loaded isn't in the cache. And, when I switch to the persistent
> store using the cocoon.xconf <cache> element, the persistent store is
> picked by CacheImpl, but still the first page isn't in the cache, even
> after multiple runs.
> 
> By "after Cocoon has restarted" I'm referring to the fact that, each
> time you invoke the CLI, Cocoon starts up from scratch, does its work,
> and then shuts down. So anything in a transient cache presumably won't
> survive between invocations of the CLI.
> 
> > > b) How can I get Cocoon to use a persisitent store for CLI and a
> > > transient one for  servlet? 
> > > 
> > By using different configurations, ok dumb answer I know, but the
> > easiest (?) solution is to change the above mentioned store
> > parameter to the required values.
> 
> Not dumb. But I tried it, but the page still wasn't in the cache after
> Cocoon had restarted (through debugging in Eclipse), and I could see
> that CacheImpl was loading a DefaultStore rather than a
> MRUMemoryStore. And default store is based upon Jisp, which is
> persistent, no?
> 
> I'll have more of a look this evening to see if I can spot why it
> isn't working. Can you give me any pointers to where I should look?
> 
> Thanks for your help here. I'm pretty green when it comes to caching
> in Cocoon, but I'm improving rapidly!

I've just done a further check which makes this problem easier to see:
1) add the <cache><parameter name="store" 
value="org.apache.excalibur.store.Store"/> </cache> thing to cocoon.xconf. 
2) Start Cocoon in Jetty
3) Load a page to get something into the cache, e.g: 
http://localhost:8888/samples/hello-world/
4) Go to http://localhost:8888/samples/status.html and you'll see your pages in the 
default store. Correct.
5) Shut down Jetty and restart
6) Go back to http://localhost:8888/samples/status.html and you're pages have 
disappeared from the default store. Surely this is wrong!

Regards, Upayavira


RE: Switching cache to Persistent Store

Posted by Upayavira <uv...@upaya.co.uk>.
On 11 Aug 2003 at 12:06, Carsten Ziegeler wrote:

> Upayavira wrote:
> > 
> > I've been exploring how to get the CLI to use Cocoon's caching
> > mechanism and  environment.isLastModified() to prevent the CLI from
> > generating otherwise cached  pages. 
> > 
> > The problem I currently have is that the cache Cocoon uses is 
> > transient, and is  
> > thus lost every time the CLI restarts.  
> > 
> > So: 
> > a) How can I switch Cocoon to always use a Persistent cache? Putting
> >  <cache><parameter name="store" 
> > value="org.apache.excalibur.store.Store"/></cache> into cocoon.xconf
> > makes  CacheImpl pick a persistent store, but for some reason values
> > aren't in the store  after Cocoon has been restarted. 

> What do you mean by "after Cocoon has been restarted"? I'm not sure
> but it could be possible that the store is cleaned on startup.

All I know is that, when the store is transient, the first page that is loaded isn't in the 
cache. And, when I switch to the persistent store using the cocoon.xconf <cache> 
element, the persistent store is picked by CacheImpl, but still the first page isn't in the 
cache, even after multiple runs.

By "after Cocoon has restarted" I'm referring to the fact that, each time you invoke the 
CLI, Cocoon starts up from scratch, does its work, and then shuts down. So anything 
in a transient cache presumably won't survive between invocations of the CLI.
 
> > b) How can I get Cocoon to use a persisitent store for CLI and a
> > transient one for  servlet? 
> > 
> By using different configurations, ok dumb answer I know, but the
> easiest (?) solution is to change the above mentioned store parameter
> to the required values.

Not dumb. But I tried it, but the page still wasn't in the cache after Cocoon had 
restarted (through debugging in Eclipse), and I could see that CacheImpl was loading 
a DefaultStore rather than a MRUMemoryStore. And default store is based upon Jisp, 
which is persistent, no?

I'll have more of a look this evening to see if I can spot why it isn't working. Can you 
give me any pointers to where I should look?

Thanks for your help here. I'm pretty green when it comes to caching in Cocoon, but 
I'm improving rapidly!

Regards, Upayavira


RE: Switching cache to Persistent Store

Posted by Carsten Ziegeler <cz...@s-und-n.de>.
Upayavira wrote:
> 
> I've been exploring how to get the CLI to use Cocoon's caching 
> mechanism and  
> environment.isLastModified() to prevent the CLI from generating 
> otherwise cached  
> pages. 
> 
> The problem I currently have is that the cache Cocoon uses is 
> transient, and is  
> thus lost every time the CLI restarts.  
> 
> So: 
> a) How can I switch Cocoon to always use a Persistent cache? Putting  
> <cache><parameter name="store"  
> value="org.apache.excalibur.store.Store"/></cache> into 
> cocoon.xconf makes  
> CacheImpl pick a persistent store, but for some reason values 
> aren't in the store  
> after Cocoon has been restarted. 
What do you mean by "after Cocoon has been restarted"? I'm not sure
but it could be possible that the store is cleaned on startup.

> b) How can I get Cocoon to use a persisitent store for CLI and a 
> transient one for  
> servlet? 
> 
By using different configurations, ok dumb answer I know, but the
easiest (?) solution is to change the above mentioned store parameter
to the required values.

Carsten