feulf / raintpl3

The easiest Template Engine for PHP
https://feulf.github.io/raintpl
258 stars 57 forks source link

Possibly optimize checkTemplate function #106

Open xPaw opened 11 years ago

xPaw commented 11 years ago

I feel like this function could be optimized quite a bit by caching some variables, and not re-calculating them every time the function is called. checkTemplate is always called regardless of cache, and if you have a lot of {include}'s in your code, it's called multiple times.

What do you think?

feulf commented 11 years ago

complex to solve: memcached and APC are server specific session are slow and each user has its own

A fast solution it could be with a watch script (crontab or screen) that compile the template when they change, and on the Tpl class a configuration that tell RainTpl to just load the template, something like $conf["compile_template"] = false;.

With APC enabled this will go even faster.

xPaw commented 11 years ago

I think memcached/apc support would be great, perhaps just have user define their own get/set functions for cache, so they can use their existing memcached connections. And if these are not defined, fall back to how it is right now.

feulf commented 11 years ago

that could be nice, I think the best way is to have a cache plugin where to implement all these features

thedavidscherer commented 10 years ago

A super simple solution along the lines of what @rainphp mentioned would be a config option to skip_compile and add a script that compiles all the templates in the defined template folders, and moves these to the cache/compiled folder. If skip_compile === true then just load the template directly from the cache dir. :)