You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by DeWitt Clinton <de...@unto.net> on 2002/04/07 18:50:57 UTC
[ANNOUNCE] Cache::Cache 1.0
Hi,
The following is an announcement of Cache::Cache 1.0. Please read the
summary below for more details.
I want to ask a special favor of the modperl community (who tend to
get a lot of mileage out of this code) -- I'm concerned with the use
of Digest::MD5, particularly version 2.16, which is used by the code
to generate unique filenames in the file-based cache. I've been
seeing some pretty ugly bugs with the the MD5 code, and this has been
confirmed on a few mailing lists and CPAN bug reports. Please let me
know if you notice any weird behavior with your system after upgrading
to version 1.0. (All unit test pass consistently, but under certain
conditions, such as when XML::DOM is loaded, I think that Digest::MD5
may always return the same hash, no matter what the key.)
Note that you can simply run Digest::MD5 2.12 and not 2.16 if you have
any issues in production. So don't worry about upgrading to version
1.0 of Cache::Cache.
I'm thinking of switching to Digest::SHA1 in version 1.01 to avoid
this until a new version of Digest::MD5 is released. Does anyone know
of a reason to avoid that? (SHA1 is slightly slower, but very little
time in spent generating keys anyway, so it may not be a big deal.)
For more information on the MD5 issue, please see:
http://rt.cpan.org/NoAuth/Bug.html?id=362.
Thanks to everyone for your help. Cheers,
-DeWitt
Summary:
The Cache modules are designed to assist a developer in persisting
data for a specified period of time. Often these modules are used
in web applications to store data locally to save repeated and
redundant expensive calls to remote machines or databases. People
have also been known to use Cache::Cache for its straightforward
interface in sharing data between runs of an application or
invocations of a CGI-style script or simply as an easy to use
abstraction of the filesystem or shared memory.
Release Notes:
Release of Cache::Cache version 1.0. This version fixes outstanding
issues on Win32 platforms and other minor bug fixes.
Project Homepage:
http://perl-cache.sourceforge.net/
Tar/GZ:
http://prdownloads.sourceforge.net/perl-cache/Cache-Cache-1.0.tar.gz
http://www.cpan.org/authors/id/D/DC/DCLINTON/Cache-Cache-1.0.tar.gz
Changelog:
http://sourceforge.net/project/shownotes.php?release_id=83292
CVS tree (viewcvs):
http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/perl-cache/
The following is the Cache-Cache-1.0 README file:
Copyright (C) 2001 DeWitt Clinton All Rights Reserved
You may distribute under the terms of either the GNU General Public
License or the Artistic License, as specified in the Perl README file.
NAME
Cache::Cache
DESCRIPTION
The Cache modules are designed to assist a developer in persisting
data for a specified period of time. Often these modules are used
in web applications to store data locally to save repeated and
redundant expensive calls to remote machines or databases. People
have also been known to use Cache::Cache for its straightforward
interface in sharing data between runs of an application or
invocations of a CGI-style script or simply as an easy to use
abstraction of the filesystem or shared memory.
The Cache package provides Cache::Cache, a generic interface
for creating persistent data stores. This interface is implemented
by the Cache::MemoryCache, Cache::SharedMemoryCache, Cache::FileCache,
Cache::SizeAwareFileCache, Cache::SizeAwareMemoryCache, and
Cache::SizeAwareSharedMemoryCache classes.
This work aggregates and extends the obsolete File::Cache and
IPC::Cache projects.
REQUIREMENTS
Digest::MD5
Error
File::Spec
File::Path
IPC::ShareLite
Storable
INSTALLATION
perl Makefile.PL
make
make test
make install
USAGE
First, choose the best type of cache implementation for your needs.
The simplest cache is the MemoryCache, which is suitable for
applications that are serving multiple sequential requests, and
wish to avoid making redundant expensive queries, such as an
Apache/mod_perl application talking to a database. If you wish to
share that data between processes, then perhaps the
SharedMemoryCache is appropriate, although its behavior is tightly
bound to the underlying IPC mechanism, which varies from system to
system, and is unsuitable for large objects or large numbers of
objects. When the SharedMemoryCache is not acceptable, then
FileCache offers all of the same functionality with similar
performance metrics, and it is not limited in terms of the number of
objects or their size. If you wish to maintain a strict limit on
the size of a file system based cache, then the SizeAwareFileCache
is the way to go. Similarly, the SizeAwareMemoryCache and the
SizeAwareSharedMemoryCache add size management functionality
to the MemoryCache and SharedMemoryCache classes respectively.
Using a cache is simple. Here is some sample code for instantiating
and using a file system based cache.
use Cache::FileCache;
my $cache = new Cache::FileCache( );
my $customer = $cache->get( $name );
if ( not defined $customer )
{
$customer = get_customer_from_db( $name );
$cache->set( $name, $customer, "10 minutes" );
}
return $customer;
Please refer to the perldoc for Cache::Cache and the related
implementations for complete documentation.
INCOMPATIBLE CHANGES
Cache::Cache 0.99 contains the following incompatible changes:
* Error::Simple is thrown on exceptions
* the get_identifiers method has been deprecated in favor of the
get_keys method
* the internal format of object in a FileCache has been modified,
necessitating a clearing of the cache while upgrading (make test
does this for the standard cache root)
SEE ALSO
The project homepage at http://perl-cache.sourceforge.net
AUTHOR
Original author: DeWitt Clinton <de...@unto.net>
Copyright (C) 2001 DeWitt Clinton
Re: [ANNOUNCE] Cache::Cache 1.0
Posted by DeWitt Clinton <de...@unto.net>.
On Sat, Apr 13, 2002 at 04:33:11PM +0200, Eric Cholet wrote:
> I'm seeing this problem when using Apache::SOAP, using Cache::Cache
> 0.99 or 1.0. Downgrading to Digest::MD5 2.12 indeed solves it.
Hi -- I recently released version 1.01 of Cache::Cache to CPAN. This
version uses Digest::SHA1 as a substitute for MD5 until the bugs in
that library are fixed. If anyone has any issues with 1.0 and MD5,
please download 1.01 and let me know if anything goes wrong.
Cheers,
-DeWitt
Re: [ANNOUNCE] Cache::Cache 1.0
Posted by Eric Cholet <ch...@logilune.com>.
--On dimanche 7 avril 2002 12:50 -0400 DeWitt Clinton <de...@unto.net>
wrote:
> Hi,
>
> The following is an announcement of Cache::Cache 1.0. Please read the
> summary below for more details.
>
> I want to ask a special favor of the modperl community (who tend to
> get a lot of mileage out of this code) -- I'm concerned with the use
> of Digest::MD5, particularly version 2.16, which is used by the code
> to generate unique filenames in the file-based cache. I've been
> seeing some pretty ugly bugs with the the MD5 code, and this has been
> confirmed on a few mailing lists and CPAN bug reports. Please let me
> know if you notice any weird behavior with your system after upgrading
> to version 1.0. (All unit test pass consistently, but under certain
> conditions, such as when XML::DOM is loaded, I think that Digest::MD5
> may always return the same hash, no matter what the key.)
I'm seeing this problem when using Apache::SOAP, using Cache::Cache 0.99
or 1.0. Downgrading to Digest::MD5 2.12 indeed solves it.
--
Eric Cholet
Re: [ANNOUNCE] Cache::Cache 1.0
Posted by DeWitt Clinton <de...@unto.net>.
On Sun, Apr 07, 2002 at 08:52:59PM +0300, Issac Goldstand wrote:
> So how exactly is the auto_purge meant to be used - the
> documentation is very hazy on that point (sure I can patch it - but
> you have to explain it to me first :)), and I just got lost when
> looknig at the module source.
The auto_purge functionality is designed to enable a cache to delete
expired cache entries periodically. While user code could call the
purge( ) method every time they access the cache, it would be rather
inefficient and often completely unnecessary. Thus the auto_purge
code automatically calls purge( ) after a user specified interval of
time has elapsed.
You set the amount of time between auto_purges by setting the
'auto_purge_interval' option when instantiating the cache.
After setting the 'auto_purge_interval' the purge method will be
called when a cache instance is created (via 'new') and the time
interval has elapsed.
Also, by setting 'auto_purge_on_set' to true, the cache will
automatically call purge when the 'set' method is called and the time
interval has elapsed.
Respectively, by setting 'auto_purge_on_get' to true, the cache will
automatically call purge when the 'get' method is called and the time
interval has elapsed.
If you tend to instantiate caches relatively frequently (such as
during the initialization of a modperl process), you can probably get
away with simply setting the 'auto_purge_interval'. However, if you
processes run for a long time and you'd like to automatically call
purge( ) more frequently, you can could consider using the
'auto_purge_on_set' option. I'd be surprised if people were using the
'auto_purge_on_get' functionality, as it would most likely be
overkill.
Also, keep in mind that if you hit the same keys over and over again,
then it may be sufficient to rely on 'get' to delete expired entries
when they are requested.
Hope this helps clarify things! Cheers,
-DeWitt
Re: [ANNOUNCE] Cache::Cache 1.0
Posted by Issac Goldstand <ma...@beamartyr.net>.
DeWitt Clinton wrote:
[snip]
I've actually meanty to ask this for a while: I'm curious as to the
auto_purge functionality of Cache::Cache - especially under mod_perl...
I tend to use it a lot, but from time to time, which is basically EVERY
time I look at /tmp, I notice bunches of stale entries from
Cache::FileCaches - and that's on the development server. So how
exactly is the auto_purge meant to be used - the documentation is very
hazy on that point (sure I can patch it - but you have to explain it to
me first :)), and I just got lost when looknig at the module source.
So:
1)What is it meat to do
2) How should it be used
3) What about constistancy issues between processes - when will perl
forget what's in the cache and not clean it up?
Thanks,
Issac