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?
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?