phptal / PHPTAL

PHP Template Attribute Language — template engine for XSS-proof well-formed XHTML and HTML5 pages
http://phptal.org
GNU Lesser General Public License v2.1
176 stars 42 forks source link

Add support for subpaths in the codedestination #37

Closed usox closed 7 years ago

usox commented 9 years ago

When using tal with a high amount of different templates and macros (I'm talking about millions of different templates), the code destination folder gets filled up with cache files within no time - especially if you dont want to clear the directory every 10 minutes. This slows down the filesystem access to the specific directory (depends on the environment - filesystemtype, nfs, etc.).

This patch introduces a configurable level of subpaths which are added to the phpCodeDestination to create a structure of max 32 subpaths with 0 as default to avoid impacts on existing installations.

Ocramius commented 9 years ago

millions of different templates

This... is very fishy. What is the use-case here? Why are there so many templates? (Can't imagine that user input is involved)

Potherca commented 9 years ago

In general I am not against adding subpath support but I do agree with @Ocramius that, if this were to be added, the logic for it should be kept out of the PHPTAL class to avoid bloat (both now and for future additions).

usox commented 9 years ago

@Ocramius We're using phptal to create highly customizable emails and webpages. Our render engine allows a nearly unlimited amount of nested templates and template-parts which are created using separate phptal render processes (having 10+ separate phptal render processes for a single webpage is not unusual). That's the reason, we create millions of cache files within hours and already had some inode-related trouble with the filesystems on our servers.

Ocramius commented 9 years ago

That's the reason, we create millions of cache files within hours and already had some inode-related trouble with the filesystems on our servers.

Considering that, did you check if there is a high impact by just not using the caches at all?

usox commented 9 years ago

Considering that, did you check if there is a high impact by just not using the caches at all?

Yep, we ran into some performance issues which of course depend on the templates and the level of customization. The current TTL of the templates is 3 days...

usox commented 9 years ago

In general, there is no urge to get this code merged as we maintain our own phptal fork with a set of patches. If you/we decide, it would be a nice idea for a coming CacheHandler/Writer/Reader/whatever, I would write it that way. If our case it too edgy for the offical repo, I will continue patching phptal myself :)