Skip Menu |

This queue is for tickets about the CHI CPAN distribution.

Report information
The Basics
Id: 127143
Status: new
Priority: 0/
Queue: CHI

People
Owner: Nobody in particular
Requestors: mbow.gora [...] gmail.com
Cc:
AdminCc:

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



Subject: Deep recursion when configuring CHI with l1cache + default storage
Date: Tue, 18 Sep 2018 23:38:34 +0200
To: bug-chi [...] rt.cpan.org
From: gora mbow <mbow.gora [...] gmail.com>
Hello, Consider a subclass of CHI with a config where the default storage uses an l1_cache. When the object is instantiated, it turns out that its l1_cache itself has a l1_cache as well. This generates infinite recursion on the fist set. Code : { package My::CHI; use base ('CHI'); __PACKAGE__->config({ storage => { mixed => { driver => "File", root_dir => "tmp/local_file", l1_cache => { driver => "Memory", global => 1 } } }, defaults => { storage => "mixed" }, }); } my $cache = My::CHI->new(namespace => "foo"); print "cache has subcaches : ", $cache->has_subcaches, "\n"; print "l1 cache has subcaches : ", $cache->l1_cache->has_subcaches, "\n"; print "trying to set...\n"; $cache->set(qw/bar zoo/); Output : cache has subcaches : 1 l1 cache has subcaches : 1 trying to set... Deep recursion on subroutine "Role::Tiny::_COMPOSABLE::CHI::Driver::Role::HasSubcaches::set" at /usr/local/share/perl/5.22.1/CHI/Driver/Role/HasSubcaches.pm line 88. Deep recursion on anonymous subroutine at (eval 61) line 16. I am runing Perl 5.22 on Ubuntu 14, with latest CHI 0.60, but I guess the issue can occur anywhere. One last remark : if you remove configuration key "defaults" from the above code and instead pass the storage name directly to the constructor, like : my $cache = My::CHI->new(namespace => "foo", storage => "mixed"), then it works just fine. I can work around the issue in my own code now that I have isolated it but still it would be nice to fix it so nobody else gets hurts. Would be glad to help if you need. Thanks ! Gora