[Catalyst] Singleton or Memcache

Matthias Ludwig matthias at kl-mailer.de
Tue Oct 17 12:34:52 CEST 2006


> Don't use a singleton. Instead, devise a Catalyst::Model api for
> your tree structure, so that you can do:
> 
> 	$c->model("MyTree")->get_that_node($which);
> 	$c->model("MyTree")->get_the_root_node;
> 
> or whatever.

makes sense :)

> You should probably pre-load this structure at setup time to get it
> to be shared between all the child processes, but if it grows too
> big to be pre-loaded you can have the tree lazily load itself using
> a cascade of caches.

Ok, good idea! next problem ;)
Is it possible to reach DBIx::Class-models while loading my own module?

In my controllers i can use objects in the database-table like this:
$c->model('MyAppDB::XXX') but i don't have access to the context while
preloading my tree?!
Do i have to controlle the db-access by myself or is there any way to
use the nice models?

> Using Cache::Cascade you can keep a small (several tens or hundreds
> of objects) cached per child process, and a memcached for another N
> mb, and then the least popular nodes will be loaded from the DB, and
> stored in the cache only when they're actually used.
> 
> Essentially, what I'm saying is that $n MB is too large a structure
> to be useful for one cache entry. Scale it down, and divide it into
> smaller chunks, and then cache those if at all.
> 
> However, when $n is 10 and not 100 it should be enough to just
> preload it.

Thanks a lot, i will keep this in my mind..




More information about the Catalyst mailing list