in reply to Re: Re: How to store CODE ref
in thread How to store CODE ref

You can store your templates in some file cache or database in source form. On each requiest you should check if cache have been updated (just check timestamp of relevant files). If it have been updated you need to recompile template from cache. If it haven't been updated you can use already compiled templates. This is how HTML::Mason handles its components (as example).

Replies are listed 'Best First'.
Re: Re: Re: Re: How to store CODE ref
by gildir (Pilgrim) on Nov 29, 2001 at 13:42 UTC
    Still not feasible solution. Most of the templates contain embeded perl code. If I would compile them in every Apache process separatly, I will get size_of_compiled_code*number_of_httpd_processes memory consumption. On a large system (hundreds of httpd processes) even a small size of templates will require much memory, and I have quite a large templates.

    In addition to this, they are user-customizable, so I accept that the size of whole bunch of templates will be considerable, too much to store in-memory.

      Sorry, but there is no alternative yet. Either you preload your data before Apache forks or it will be duplicated in all childs. No caching solution can help you share that memory between Apache childs.

      You have to wait for Apache 2.0 with mod_perl 2.0 which use threads.