Skip Menu |

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

Report information
The Basics
Id: 118809
Status: new
Priority: 0/
Queue: Template-Plugin-Cache

People
Owner: Nobody in particular
Requestors: mfontani [...] cpan.org
Cc:
AdminCc:

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



Subject: same "keys" key/values produce different "cache key" to cache with
This is likely to be a byproduct of "recent" Perl changes to the "Hash Traversal Randomization", i.e. see http://perldoc.perl.org/perlsec.html#Algorithmic-Complexity-Attacks The outcome of this is that for the exact same set of "keys" given to the cache, i.e.: foo_cache.proc('name.tt', ttl => 30, keys => { foo => 1, bar => 1, baz => 1, }); … Template::Plugin::Cache will create many different "cache keys" internally, i.e. its code: my $cache_keys = $params->{keys}; $key = join( ':', ( $params->{template}, map { "$_=$cache_keys->{$_}" } keys %{$cache_keys} ) ); will produce, given the input above, a $key which is going to be any of: name.tt:foo=1:bar=1:baz=1 name.tt:foo=1:baz=1:bar=1 name.tt:bar=1:foo=1:baz=1 name.tt:bar=1:baz=1:foo=1 name.tt:baz=1:bar=1:foo=1 name.tt:baz=1:foo=1:bar=1 For users of this caching module, it means that there's no guarantee that the cache _will_ be hit for that exact set of "keys" before the TTL expires. In the above case, it means that up to six caches will be distinctly created from the same set of unchanging keys, instead of just one. I guess the fix should be as simple as "adding a sort before that map", i.e.: my $cache_keys = $params->{keys}; $key = join( ':', ( $params->{template}, + sort map { "$_=$cache_keys->{$_}" } keys %{$cache_keys} ) ); Hope this helps! -marco-