[CDBI] Disabling %Live_Objects; creating a cache

John Siracusa siracusa at mindspring.com
Fri Jan 13 00:57:46 GMT 2006


On 1/12/06 7:19 PM, Perrin Harkins wrote:
> Caching database data is never all that easy.  There are complex issues
> involved.  You can try the caching in Class::DBI::Sweet or you can ditch
> Class::DBI and try Rose::DB::Object, which has caching.  I think you'll
> find it opens a can of worms, but may be worth it if your system is
> having performance problems.

Rose::DB::Object itself does not do any object caching.  Caching at the Perl
db object level is almost always a lot of effort for little gain.

That said, a subclass of Rose::DB::Object (appropriately named
Rose::DB::Object::Cached) that's bundled in the module distribution has
simple caching of single-object load() operations.  It's useful in a very
specific situation where you have a set of essentially "read-only" data in
the database that you load a row at a time. You can read more about it here:

http://search.cpan.org/dist/Rose-DB-Object/lib/Rose/DB/Object/Cached.pm

Keep I mind that Rose::DB::Object::Cached has nothing to do with
Rose::DB::Object's speed.  It is not used in the benchmark[1] suite at all.
It was created as an early proof-of-concept for subclassing, and lives on
because it's useful in the (somewhat rare) situation described above.

-John

[1] http://rose.sourceforge.net/wiki/index.php/RDBO/Benchmark






More information about the ClassDBI mailing list