Skip Menu |

This queue is for tickets about the Cache CPAN distribution.

Report information
The Basics
Id: 32339
Status: resolved
Priority: 0/
Queue: Cache

People
Owner: Nobody in particular
Requestors: justin [...] techadvise.com
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 2.04
Fixed in: (no value)



Subject: Bug in Cache::Memory regarding Namespaces
I've just written my first app that uses Cache, so I'm new to this, but, here's my issue: I have one cache that I need to keep three versions of data in. I use the version number as the namespace, but I don't know the version numbers in advance. The bug is that when you call set_namespace, it assumes the two heaps have already been setup for that namespace. Here's a test case: use Cache::Memory; my $cache = Cache::Memory->new(); #this works: $cache->set('foo','bar'); $cache->set_namespace("OtherNameSpace"); #This dies: $cache->set('foo','bar2'); Changing the set_namespace method in Memory.pm to this: sub set_namespace { my Cache::Memory $self = shift; my ($namespace) = @_; $Age_Heaps{$namespace} ||= Heap::Fibonacci->new(); $Use_Heaps{$namespace} ||= Heap::Fibonacci->new(); $self->{namespace} = $namespace; } Makes it work fine.
Hi, thanks for the report and the fix. This was fixed in Cache-2.06 that was just uploaded to CPAN (with your testcase included). Resolving this ticket. Regards, Shlomi Fish On Tue Jan 15 18:02:59 2008, justintime wrote: Show quoted text
> I've just written my first app that uses Cache, so I'm new to this, but, > here's my issue: > > I have one cache that I need to keep three versions of data in. I use > the version number as the namespace, but I don't know the version > numbers in advance. The bug is that when you call set_namespace, it > assumes the two heaps have already been setup for that namespace. > Here's a test case: > > use Cache::Memory; > my $cache = Cache::Memory->new(); > #this works: > $cache->set('foo','bar'); > $cache->set_namespace("OtherNameSpace"); > #This dies: > $cache->set('foo','bar2'); > > Changing the set_namespace method in Memory.pm to this: > sub set_namespace { > my Cache::Memory $self = shift; > my ($namespace) = @_; > $Age_Heaps{$namespace} ||= Heap::Fibonacci->new(); > $Use_Heaps{$namespace} ||= Heap::Fibonacci->new(); > $self->{namespace} = $namespace; > } > > Makes it work fine.