views:

24

answers:

1

Are RDBOC objects cached through different processes? I'm thining of running it in mod-perl, and it would factor into things, even though it would mostly be used on things that don't change (much).

Also, do relationships referencing RDBOCs use the cache when it should intuitively?

+1  A: 

Rose::DB::Object::Cached caches objects in plain-old (non-shared) memory. Under mod_perl, this means that each apache process has its own cache. You could, however, cache your objects on server startup. All of those cached objects would then be shared with each apache child process. This is most useful for read-only objects that you don't ever expect to change for the life of the server.

For more flexible caching options, check out Rose::DBx::Object::Cached::CHI.

As for your second question, Rose::DB::Object::Cached only reads from and writes to the cache on load() and save(). Most relationship methods use Manager queries to get objects and so will not read from the Rose::DB::Object::Cached cache.

John Siracusa
thanks John, what do u recommend for the manager route?
Timmy
I recommend not caching anything except read-only objects. In my experience, caching at a higher level (e.g., components of pages or entire pages) or a lower level (e.g., a cache that sits in front of the database itself) tends to be more fruitful than caching at the database-object level.
John Siracusa
They're, 99% of the time read-only. Maybe very minor things that will change, but they will be dominated by reading, and isn't necessary up to date. Almost like having a table "id, color, description" - id, color will always be the same, and description might change once in awhile, but is not necessary. I've switched over to use Rose::DBx::Object::Cached::CHI to play with, and it is already helping very much, except for the uncertainty with manager things.
Timmy
like, I would just like $obj->color->description to be cached, for instance
Timmy
If those are all …-to-one relationships, then load() should actually be called, which will hit the cache.
John Siracusa
they r foreign keys, which should be a "to-one". thanks!
Timmy