Skip Menu |
 

This queue is for tickets about the Cache-Cache CPAN distribution.

Report information
The Basics
Id: 19586
Status: new
Priority: 0/
Queue: Cache-Cache

People
Owner: Nobody in particular
Requestors: dan.horne [...] redbone.co.nz
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: (no value)
Fixed in: (no value)



Subject: Add busy_locK
Download (untitled) / with headers
text/plain 1.3k
HTML::Mason has a "busy_lock" solution to deal with race conditions where too many processes may wish to update an expired cache on a busily accessed site. This would be a useful core addition to Cache::Cache for non Mason users. To explain what I mean, I've quoted the Mason docs below: "The code shown in ``Basic Usage'' above, my $result = $m->cache->get('key'); if (!defined($result)) { ... compute $result ... $m->cache->set('key', $result); } can suffer from a kind of race condition for caches that are accessed frequently and take a long time to recompute. Suppose that a particular cache value is accessed five times a second and takes three seconds to recompute. When the cache expires, the first process comes in, sees that it is expired, and starts to recompute the value. The second process comes in and does the same thing. This sequence continues until the first process finishes and stores the new value. On average, the value will be recomputed and written to the cache 15 times! Mason offers a solution with the busy_lock flag: my $result = $m->cache->get('key', busy_lock=>'30 sec'); In this case, when the value cannot be retrieved, get() sets the expiration time of the value 30 seconds in the future before returning undef. This tells the first process to compute the new value while causing subsequent processes to use the old value for 30 seconds."


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.