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

Reply via email to