You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jcs-dev@jakarta.apache.org by Eric Wolf <Er...@bcbsks.com> on 2007/03/13 23:16:37 UTC

disk caching persistence

In the documentation, it is stated:

"Persistence"

"When the disk cache is properly shutdown, the memory index is written to disk 
and the value file is defragmented. When the cache starts up, the disk cache 
can be configured to read or delete the index file. This provides an unreliable 
persistence mechanism."

I wanted to know how to "the disk cache can be configured to read or delete
the index file".  I wanted to set it to read to use caching as a way to
have my application functional while off-line of the databases.  I could not 
find how to do this anywhere in the documentation.  The "DiskUsagePattern"
seems to hint about it if you set it to UPDATE, but that only forces things
to disk.  It doesn't mention configuring the disk cache to read the index
file at start up.  Does someone know how to do this?

Secondary question: How do you make sure of shutting down the disk cache
properly?

Thanks in advance,
Eric


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


Re: disk caching persistence - solved

Posted by Eric Wolf <Er...@bcbsks.com>.
Thanks Aaron.  Your previous response did the trick.  It is working as I needed 
and as you stated.

Thanks again,
Eric Wolf






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


Re: disk caching persistence

Posted by Aaron Smuts <as...@yahoo.com>.
I saw your question, I just didn't understand what you
were asking.

Maybe I can clarify.  


About the indexed disk cache:

The indexed disk cache stores data on disk and the
keys in memory.  When you ask for an item by key, it
looks in its memory key store for the key.  The value
associated with this key is the offset on disk.  The
disk cache goes to this spot, reads teh first byte to
determine the size and then reads the item.  

The keys are only written to disk during optimization
and shutdown.  (We could add some kind of hook that
would allow you to flush them, or do it periodically.
. . .)


About shut down disk persistence:

If you call shutdown on the composite cache manager
the cache will shutdown properly.  It will try to push
all items in memory to disk if the disk is configured.
 For webapps, I register a context listener in my
web.xml.


<listener>
<listener-class>

org.apache.jcs.utils.servlet.JCSServletContextListener
</listener-class>
</listener>
</pre>

The disk cache registers a shutdown hook.  When the vm
exits, it will try to write the keys to disk if it
hasn't been shutdown properly.

If you set the disk usage pattern to UPDATE, all items
will be sent to disk when they are added to the cache.
   If you call shutdown on the composite cache
manager, it doesn't need to send all teh items to the
disk auxiliary.  They should already be there.  


About startup:

When the cache starts up, if you are using a disk
cache for any region then the indexed disk cache will
try to load the keys that were stored on shutdown.


If the item is on disk, then it's on disk.  It doesn't
matter if your database is up, down, or non-existent. 
That cache has nothing to do with it.  If you go to
the cache to get an item and it's there, then great,
perhaps you won't need to go to the datasource to get
it.  If the datasource happened to be down, then you
just saved yourself an error.  

Aaron


--- Eric Wolf <Er...@bcbsks.com> wrote:

> Aaron Smuts <asmuts <at> yahoo.com> writes:
> 
> > 
> > I'm not sure what the question is exactly.  Can
> you
> > clarify?
> > 
> > Aaron
> > 
> > --- Thomas Vandahl <tv <at> apache.org> wrote:
> > 
> > > Eric Wolf wrote:
> > > > I wanted to know how to "the disk cache can be
> > > configured to read or delete
> > > > the index file".  I wanted to set it to read
> to
> > > use caching as a way to
> > > > have my application functional while off-line
> of
> > > the databases.  I could not 
> > > > find how to do this anywhere in the
> documentation.
> > >  The "DiskUsagePattern"
> > > > seems to hint about it if you set it to
> UPDATE,
> > > but that only forces things
> > > > to disk.  It doesn't mention configuring the
> disk
> > > cache to read the index
> > > > file at start up.  Does someone know how to do
> > > this?
> > > 
> > > The code of the IndexedDiskCache suggests that
> the
> > > index file is being
> > > read if it exists and is not corrupted. I can
> see no
> > > configuration
> > > setting for this.
> > > 
> > > > Secondary question: How do you make sure of
> > > shutting down the disk cache
> > > > properly?
> > > 
> > > The IndexedDiskCache registers a Shutdown Hook
> with
> > > the runtime. So the
> > > dispose() method should be run at JVM exit the
> > > latest. In every other
> > > case if all managers associated with this cache
> call
> > > release(), the
> > > cache is disposed. During dispose() data files
> are
> > > (optionally)
> > > optimized and the key file is written.
> > > 
> > > Bye, Thomas.
> > > 
> 
> The two part question that started this thread is as
> follows:
> 
> In the JCS documentation, it is stated:
> 
> Persistence
> When the disk cache is properly shutdown, the memory
> index is written to disk 
> and the value file is defragmented. When the cache
> starts up, the disk cache 
> can be configured to read or delete the index file.
> This provides an unreliable 
> persistence mechanism. 
> 
> I wanted to know how to make "the disk cache can be
> configured to read or 
> delete the index file".  I wanted to set it to read
> to use caching as a way to 
> have my application functional while off-line of the
> databases.  I couldn't 
> find how to do this anywhere in the documentation. 
> The "DiskUsagePattern" 
> seems to hint about it if you set it to UPDATE, but
> that only forces things to 
> disk.  It doesn't mention configuring the disk cache
> to read the index file at 
> start up.  If you could show me how to do that, I
> would greatly appreciate it.
> 
> Secondary question: How do you make sure of shutting
> down the disk cache 
> properly?
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> jcs-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:
> jcs-dev-help@jakarta.apache.org
> 
> 


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


Re: disk caching persistence

Posted by Eric Wolf <Er...@bcbsks.com>.
Aaron Smuts <asmuts <at> yahoo.com> writes:

> 
> I'm not sure what the question is exactly.  Can you
> clarify?
> 
> Aaron
> 
> --- Thomas Vandahl <tv <at> apache.org> wrote:
> 
> > Eric Wolf wrote:
> > > I wanted to know how to "the disk cache can be
> > configured to read or delete
> > > the index file".  I wanted to set it to read to
> > use caching as a way to
> > > have my application functional while off-line of
> > the databases.  I could not 
> > > find how to do this anywhere in the documentation.
> >  The "DiskUsagePattern"
> > > seems to hint about it if you set it to UPDATE,
> > but that only forces things
> > > to disk.  It doesn't mention configuring the disk
> > cache to read the index
> > > file at start up.  Does someone know how to do
> > this?
> > 
> > The code of the IndexedDiskCache suggests that the
> > index file is being
> > read if it exists and is not corrupted. I can see no
> > configuration
> > setting for this.
> > 
> > > Secondary question: How do you make sure of
> > shutting down the disk cache
> > > properly?
> > 
> > The IndexedDiskCache registers a Shutdown Hook with
> > the runtime. So the
> > dispose() method should be run at JVM exit the
> > latest. In every other
> > case if all managers associated with this cache call
> > release(), the
> > cache is disposed. During dispose() data files are
> > (optionally)
> > optimized and the key file is written.
> > 
> > Bye, Thomas.
> > 

The two part question that started this thread is as follows:

In the JCS documentation, it is stated:

Persistence
When the disk cache is properly shutdown, the memory index is written to disk 
and the value file is defragmented. When the cache starts up, the disk cache 
can be configured to read or delete the index file. This provides an unreliable 
persistence mechanism. 

I wanted to know how to make "the disk cache can be configured to read or 
delete the index file".  I wanted to set it to read to use caching as a way to 
have my application functional while off-line of the databases.  I couldn't 
find how to do this anywhere in the documentation.  The "DiskUsagePattern" 
seems to hint about it if you set it to UPDATE, but that only forces things to 
disk.  It doesn't mention configuring the disk cache to read the index file at 
start up.  If you could show me how to do that, I would greatly appreciate it.

Secondary question: How do you make sure of shutting down the disk cache 
properly?


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


Re: disk caching persistence

Posted by Aaron Smuts <as...@yahoo.com>.
I'm not sure what the question is exactly.  Can you
clarify?

Aaron


--- Thomas Vandahl <tv...@apache.org> wrote:

> Eric Wolf wrote:
> > I wanted to know how to "the disk cache can be
> configured to read or delete
> > the index file".  I wanted to set it to read to
> use caching as a way to
> > have my application functional while off-line of
> the databases.  I could not 
> > find how to do this anywhere in the documentation.
>  The "DiskUsagePattern"
> > seems to hint about it if you set it to UPDATE,
> but that only forces things
> > to disk.  It doesn't mention configuring the disk
> cache to read the index
> > file at start up.  Does someone know how to do
> this?
> 
> The code of the IndexedDiskCache suggests that the
> index file is being
> read if it exists and is not corrupted. I can see no
> configuration
> setting for this.
> 
> > Secondary question: How do you make sure of
> shutting down the disk cache
> > properly?
> 
> The IndexedDiskCache registers a Shutdown Hook with
> the runtime. So the
> dispose() method should be run at JVM exit the
> latest. In every other
> case if all managers associated with this cache call
> release(), the
> cache is disposed. During dispose() data files are
> (optionally)
> optimized and the key file is written.
> 
> Bye, Thomas.
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> jcs-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:
> jcs-dev-help@jakarta.apache.org
> 
> 


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


Re: disk caching persistence

Posted by Thomas Vandahl <tv...@apache.org>.
Eric Wolf wrote:
> I wanted to know how to "the disk cache can be configured to read or delete
> the index file".  I wanted to set it to read to use caching as a way to
> have my application functional while off-line of the databases.  I could not 
> find how to do this anywhere in the documentation.  The "DiskUsagePattern"
> seems to hint about it if you set it to UPDATE, but that only forces things
> to disk.  It doesn't mention configuring the disk cache to read the index
> file at start up.  Does someone know how to do this?

The code of the IndexedDiskCache suggests that the index file is being
read if it exists and is not corrupted. I can see no configuration
setting for this.

> Secondary question: How do you make sure of shutting down the disk cache
> properly?

The IndexedDiskCache registers a Shutdown Hook with the runtime. So the
dispose() method should be run at JVM exit the latest. In every other
case if all managers associated with this cache call release(), the
cache is disposed. During dispose() data files are (optionally)
optimized and the key file is written.

Bye, Thomas.

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