file: $CPAN/authors/id/J/JS/JSWARTZ/CHI-0.03.tar.gz
size: 62313 bytes
md5: ec828f2466ba266e11cd6d1dd5ca2913
CHI provides a unified caching API, designed to assist a developer in persisting data for a specified period of time. It is intended as an evolution of DeWitt Clinton's Cache::Cache package, adhering to the basic Cache API but adding new features and addressing limitations in the Cache::Cache implementation.
You might think of it as a fledgling "DBI for caching".
Driver classes already exist for in-process memory, plain files, memory mapped files and memcached. Other drivers such as BerkeleyDB and DBI will be coming soon. Fortunately, implementing drivers is fairly easy, on the order of creating a TIE interface to your data store.
Special thanks to the Hearst Digital Media group, where CHI was first designed and developed, for blessing the open source release of this code.
There's lots more in store for this module, so stay tuned! Feedback welcome here or on the Perl cache mailing list.
Nice (Score:1)
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:
Re: (Score:1)
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...
Re: (Score:1)
Sorry, that should have read:
Re: (Score:1)
I like the complex key idea, though.