pauamma: Cartooney crab wearing hot pink and acid green facemask holding drink with straw (Default)
Res facta quae tamen fingi potuit ([personal profile] pauamma) wrote in [site community profile] dw_dev2010-05-12 09:33 pm
Entry tags:

Using LJ::Typemap outside web context: how to initialize LJ::MemCache?

LJ::Typemap calls LJ::MemCache, but doesn't actually "use LJ::MemCache;" or call LJ::MemCache::init, relying instead on ljlib.pl to do both. In web context, ljlib.pl is loaded through Apache::LiveJournal, and for worker processes, through LJ::Worker::Manual. For other executables (eg, proof of concept, throwaway learning tools, etc) which don't fall in either category, what should happen?

Options are:
1- Make LJ::Typemap (and everything else that relies on LJ::MemCache) use it and initialize it explicitely. This requires changes to LJ::MemCache, because LJ::MemCache::init isn't currently idempotent.
2- Require all programs using LJ::MemCache to use base 'LJ::Worker::Manual'; (but that in turn requires making them workers, with a LJ::Worker::Foo package that's started from main, which is awkward for throw-away programs).
3- Make LJ::MemCache initialize itself when loaded, and remove explicit initialization from everywhere else that uses it, but that's extensive.
4- Something else I forgot.

I'm leaning toward 2 ATM. Anyone has a better solution, an opinion, or comments?

Post a comment in response:

If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting

If you are unable to use this captcha for any reason, please contact us by email at support@dreamwidth.org