[Dbix-class] REPOST: memcache / DBIx::Class

Brandon Black blblack at gmail.com
Wed May 30 00:46:19 GMT 2007


On 5/29/07, Oleg Pronin <syber.rus at gmail.com> wrote:
> How do you plan to deal with multiprocess web-servers ?
> Separate processes do not know what the others change.
>
> The only solution i found is to cache data for some time (based on how much
> realtime do you need).

memcached is designed to handle this, both for multiple processes on
one webserver and multiple webservers in a datacenter.  However, you
have to wrap memcached with cache invalidation (custom for all of your
data access).  The generic pattern (not specific to DBI or
DBIx::Class) is that you wrap your real database API in a higher-level
API of getter/setter methods, and do something like:

sub get_foo {
    # return memcache entry if available, populate it from the DB and
return it if not
}

sub set_foo {
    # Set the new value in the DB and update the memcache entry too
}

But this solution doesn't generalize to all of DBIx::Class access very
well without parsing WHERE clauses.

-- Brandon



More information about the Dbix-class mailing list