Storing code references

37 views
Skip to first unread message

Steven Haryanto

unread,
Feb 15, 2012, 11:31:17 PM2/15/12
to Perl-Cache Discuss
Hi,

Any advice on storing code references using CHI? My module is
generating subroutine wrappers, and I'm caching a certain number of
these in memory. I usually use Tie::Cache for this kind of task, but
am considering CHI for (potentially) more flexibility. However, the
CHI interface passes flat binary string to the backend, so I guess CHI
is not appropriate in this case?

But I'm thinking a whole class of cases where the cache data is not
serializable. Perhaps something simple like a wrapper or an API can be
created for this?

Regards,
Steven

Jonathan Swartz

unread,
Feb 16, 2012, 1:38:00 AM2/16/12
to perl-cach...@googlegroups.com
Hi Steven,

CHI::Driver::RawMemory (http://search.cpan.org/perldoc/?CHI::Driver::RawMemory) stores actual references in memory, without serializing.

Jon

> --
> You received this message because you are subscribed to the Google Groups "Perl-Cache Discuss" group.
> To post to this group, send email to perl-cach...@googlegroups.com.
> To unsubscribe from this group, send email to perl-cache-disc...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/perl-cache-discuss?hl=en.
>

Steven Haryanto

unread,
Feb 16, 2012, 2:05:28 AM2/16/12
to Perl-Cache Discuss
Hi Jon,

Ah, should've read the docs a bit more. Was thrown off by this
statement in CHI's pod: "CHI handles its own serialization, passing a
flat binary string to the underlying cache backend." Thanks!

Regards,
Steven

Perrin Harkins

unread,
Feb 16, 2012, 8:48:16 AM2/16/12
to perl-cach...@googlegroups.com
On Wed, Feb 15, 2012 at 11:31 PM, Steven Haryanto
<stevenh...@gmail.com> wrote:
> Any advice on storing code references using CHI?

My advice is to run the other direction as fast as you can, but if you
really want to, there are hooks in Storable that let you choose how to
serialize your objects.

- Perrin

Jonathan Swartz

unread,
Feb 16, 2012, 1:32:48 PM2/16/12
to perl-cach...@googlegroups.com

Or, he can use CHI::Driver::RawMemory. :)

Jonathan Swartz

unread,
Feb 16, 2012, 1:33:05 PM2/16/12
to perl-cach...@googlegroups.com
Yup, I'll mention this exception in the documentation. Thanks.
Reply all
Reply to author
Forward
0 new messages