[Catalyst] query once per session?

Yuval Kogman nothingmuch at woobling.org
Mon Apr 30 20:47:14 GMT 2007

On Mon, Apr 30, 2007 at 09:20:45 -0700, Michael Higgins wrote:

> I'm afraid this doesn't mean anything to me yet. I'm caching like this:
>     unless ( $result = $cache->get( 'clients' ) ) {
>         $result = [$c->model('BanTraceDB::TBGClient')->search(
>                          {},{ order_by=>'name ASC'}
>                           )];
>         $c->cache->set( 'clients', $result );
>         }
> I don't know what's happening 'under the hood'.

The problem is that e.g. $result->[0]->result_source is a very large
data structure, containing the entire DBIC schema definition (every
table involved in your DB is referenced in there).

If you load the aforementioned component into BanTraceDB::TBGClient
then the hook that Storable (what's used internally by most caching
modules) will call to serialize the row objects will remove the
reference to the result source and the schema, effectively saving
only the actual row data, that you you would like to save, giving
you both a performance boost and a cache size reduction.

  Yuval Kogman <nothingmuch at woobling.org>
http://nothingmuch.woobling.org  0xEBD27418

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.scsys.co.uk/pipermail/catalyst/attachments/20070430/efddbdfc/attachment.pgp

More information about the Catalyst mailing list