[Catalyst] DB values that change very rarely

Robert Rothenberg robrwo at gmail.com
Mon Jan 14 13:03:58 GMT 2013


I have a caching plugin that would be useful. Cache::HTTP::Preempt. Will
upload to CPAN soon but I am moving house now.
On Jan 14, 2013 8:18 AM, "Alexander Hartmaier" <
alexander.hartmaier at t-systems.at> wrote:

> On 2013-01-11 19:05, Francisco Obispo wrote:
> > You really don't want this in DBIx::Class, you want fine grain control
> of when to fetch from the database, etc. Anyone can build their layer on
> top of DBIx::Class to implement caching.
> >
> > Using something like memcached would save you some database hits, you
> can either set the values to expire at a specified time / number of
> seconds, or you can set/delete keys as part of the procedures at
> insert/update/delete on the database.
> >
> > If you you Postgresql, you can actually take advantage of PgPool, which
> will give you the option to enable a caching layer=85
> >
> > Francisco
> Please don't top post!
> I *do* want this in DBIC so that a prefetch specified in some query
> doesn't hit the database if the table is cached schema-wide. Any other
> caching technique would mean changing every piece of code whereas this
> would be transparent. I do know DBIx::Class quite well and don't think
> that's possible with a component.
> >
> >
> >
> > On Jan 11, 2013, at 4:01 AM, Alexander Hartmaier <
> alexander.hartmaier at t-systems.at> wrote:
> >
> >> On 2013-01-10 16:15, Jesse Sheidlower wrote:
> >>> In one of my apps, I have a number of tables that contain values that
> >>> change very rarely. Think of something like a "category" table in an
> >>> e-commerce app--they're mostly static, but every now and then you need
> >>> to change or add or delete a category. These occasional changes do,
> >>> however, need to be made by a (privileged) user, rather than a
> >>> developer, so I can't just put them in the config file and edit this
> and
> >>> restart the app when necessary. Since I don't know when they might
> >>> change, I don't know how I could cache them, because when a change is
> >>> made it needs to take effect immediately.
> >>>
> >>> These tables are used on almost every request. The result is that most
> >>> of my controllers end up looking something like this, or having
> >>> something like this at the end of them:
> >>>
> >>> sub add : Local {
> >>>   my ( $self, $c ) =3D @_;
> >>>
> >>>   $c->stash->{title} =3D 'Add a new lemma';
> >>>
> >>>   $c->stash->{batches} =3D $c->model('WordsDB::Batch')->search();
> >>>   $c->stash->{statuses} =3D $c->model('WordsDB::Status')->search();
> >>>   $c->stash->{regions} =3D $c->model('WordsDB::Region')->search();
> >>>   $c->stash->{subjects} =3D $c->model('WordsDB::Subject')->search();
> >>>
> >>>   $c->stash->{template} =3D 'add.tt';
> >>> }
> >>>
> >>> This means that almost every page generation hits the database a whole
> bunch of
> >>> unnecessary times, and that all of my controllers are cluttered.
> >>>
> >>> This must be a fairly common problem. What's the best way to deal with
> >>> it--both the desire to persist what is mostly static data, and to keep
> >>> my controllers clean?
> >>>
> >>> Thanks.
> >>>
> >>> Jesse Sheidlower
> >>>
> >>> _______________________________________________
> >>> List: Catalyst at lists.scsys.co.uk
> >>> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> >>> Searchable archive:
> http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
> >>> Dev site: http://dev.catalyst.perl.org/
> >> I'd LOVE to see that functionality in DBIx::Class::Schema so prefetches
> >> use the cached values to populate the related data instead of hitting
> >> the database.
> >>
> >> --
> >> Best regards, Alexander Hartmaier
> >>
> >>
> >>
> *"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*=
"*"*
> >> T-Systems Austria GesmbH Rennweg 97-99, 1030 Wien
> >> Handelsgericht Wien, FN 79340b
> >>
> *"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*=
"*"*
> >> Notice: This e-mail contains information that is confidential and may
> be privileged.
> >> If you are not the intended recipient, please notify the sender and th=
en
> >> delete this e-mail immediately.
> >>
> *"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*=
"*"*
> >>
> >> _______________________________________________
> >> List: Catalyst at lists.scsys.co.uk
> >> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> >> Searchable archive:
> http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
> >> Dev site: http://dev.catalyst.perl.org/
> > Francisco Obispo
> > Director of Applications and Services - ISC
> > email: fobispo at isc.org
> > Phone: +1 650 423 1374 || INOC-DBA *3557* NOC
> > PGP KeyID =3D B38DB1BE
> >
> >
> > _______________________________________________
> > List: Catalyst at lists.scsys.co.uk
> > Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> > Searchable archive:
> http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
> > Dev site: http://dev.catalyst.perl.org/
>
> --
> LG Alex
>
>
> _______________________________________________
> List: Catalyst at lists.scsys.co.uk
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive:
> http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
> Dev site: http://dev.catalyst.perl.org/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20130114/ebbcb=
f08/attachment.htm


More information about the Catalyst mailing list