[Dbix-class] memcached
Ash Berlin
ash_cpan at firemirror.com
Wed Jan 24 21:57:09 GMT 2007
Jim Spath wrote:
> I was wondering if anyone had any suggestions for how to properly use
> memcached (http://www.danga.com/memcached/) with DBIx::Class.
>
> When one tries to store a resultset in memcached, you get the error
> "Can't store CODE items", which makes sense.
>
> It seems like I really only have one choice, which is to create a
> string/arrayref/hashref of the data returned from the resultset before
> storing it in memcached and using it in my code. But that feels a
> little ugly to me.
>
> Any ideas?
>
> - Jim
>
> PS - I'm running running both DBIx::Class and Cache::Memcached under
> Catalyst, if it matters.
IIRC the CODE segment it is refereeing to is in fact the dbh deep down
in storage.
In the -current branch (which is due for release soon) we completely
refactored how objects and result sets keep hold of their
ResultSource's. Instead of storing a direct reference to a ResultSource,
they now store a tuple of (source_name,schema)
This has the added benefit that you can store only the source_name when
you put an RS into memcached, and re-attach it to the schema when you
read it out.
<http://dev.catalyst.perl.org/trac/bast/browser/branches/DBIx-Class-current/lib/DBIx/Class/ResultSourceHandle.pm>
The above file has freeze and thaw hooks for Storable, but bear in mind
that the schema is not automatically reattached (couldn't work out a
good way of doing it) so you'd have to come up with a way of expressing
it or just do something hacky like:
$newly_thawed_obj->_source_handle->schema($schema);
But please don't do that, cos it will break horribly in all kinds of cases.
</incoherent ramblings>
Ash
More information about the Dbix-class
mailing list