FAQ
This is the full configuration for my model, which includes heavy
caching (it's a readonly access to a data warehouse which gets updated
once a day):

Model::MyDB:
traits:
- Caching
- SchemaProxy
default_resultset_attributes:
cache_for: 3600 # cache results for one our
connect_info:
dsn: 'dbd:mysql:host=1.2.3.4;database=test'
user: test
password: test

The 'Caching' trait is what allows you to use the
DBIx::Class::Cursor::Cached caching. The SchemaProxy trait allows you to
specify the default_resultset_attributes once and for all resultsets in
this model, without having to specify it in every place you use a RS
from this model.

And after that you also have to configure the caching backend:

Plugin::Cache:
backend:
class: 'Cache::FastMmap'
unlink_on_exit: 1
share_file: /tmp/datafile.cache
cache_size: 32m

With this configuration I didn't have to touch a single line where
queries were being executed. Just added these lines to my Catalyst
configuration (after installing the correspoding modules, of course).
Modules that I had to install from CPAN:

Catalyst::Plugin::Cache
Cache::FastMmap
Catalyst::TraitFor::Model::DBIC::Schema::Caching
Catalyst::TraitFor::Model::DBIC::Schema::SchemaProxy
DBIx::Class::Cursor::Cached (I think this one is brought by Caching
trait as a dependency).

Regards
J.

*/Jorge González Villalonga/*
Director Técnico

*/DAIKON Integración y Desarrollo S.L./*
Telf: (+34) 91 188 08 28
Fax: (+34) 91 632 65 42
*www.daikon.es*


El 03/07/11 19:53, Eden Cardim escribió:
"Alex" == Alex Povolotsky<tarkhil@over.ru> writes:
Alex> Good; how can I set default cache_time for all searches
Alex> without explicit cache_time?

Have a look at the resultset_attributes method in
DBIx::Class::ResultSource.
-------------- next part --------------
Skipped content of type multipart/related

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 5 of 8 | next ›
Discussion Overview
groupdbix-class @
categoriesperl, catalyst
postedJul 2, '11 at 7:39a
activeJul 4, '11 at 5:32p
posts8
users5
websitedbix-class.org
irc#dbix-class

People

Translate

site design / logo © 2021 Grokbase