Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • This looks like a cool project. I particularly like the Multilevel idea.

    I've been wanting to add a caching layer to my app but one thing I've been pondering on is handling different objects in the same cache.

    I know the common solution is to prepend the object name to the key but it would be nice if this was abstracted by the cache layer itself. Perhaps an optional objectspace parameter could be added to the get/set methods? Or how about something like:

    my $cache = CHI->new( driver => 'Memory',

    • There is already support for multiple namespaces, but I take it that's not what you're looking for.

      I've been considering adding support for complex keys that are automatically serialized, so you could say:

      my $customer = $cache->get({customer => $name}); $cache->set({customer => $name}, $customer, "10 minutes" ); my $user = $cache->get({user => $name});

      which is maybe a little cleaner than prepending onto a string...

      • Sorry, that should have read:

        my $customer = $cache->get({customer => $name});
        $cache->set({customer => $name}, $customer, "10 minutes" );
        my $user = $cache->get({user => $name});
      • Right, I didn't want to use namespaces since that is set per cache object.

        I like the complex key idea, though.