Page 1 of 1

How to use APC PHP-cache for Smarty 3.x in CMSMS?

Posted: Wed Nov 04, 2015 8:43 pm
by swgreed
How can I use APC/APCU PHP in memory cache with CMSMS?

[*] nowadays, Smarty 3.1.x ships with a plugin in "/demo/plugins/cacheresource.apc.php" by default

[*] The Smarty forum offers a default solution for enabling this feature, see: http://www.smarty.net/forums/viewtopic.php?t=16809

Code: Select all

$smarty->loadCacheResource('apc');
$smarty->setCaching(true);
But I'm not sure how to combine this with Smarty within CMSMS?
Where do I put the above code?

Re: How to use APC PHP-cache for Smarty 3.x in CMSMS?

Posted: Thu Nov 05, 2015 10:02 am
by Jeff
What are you looking for the code caching or the data store?

I don't know about the CMSms side of things, but in general APC is outdated.

What are your server specs that you are doing this on?

Re: How to use APC PHP-cache for Smarty 3.x in CMSMS?

Posted: Mon Nov 09, 2015 3:02 pm
by swgreed
Hi Jeff,

I'm looking for the place in the CMSMS source code to place these 2 lines (just for testing purpoises).

I came across APCu (i.e. APC micro) while playing around with Owncloud. Since my webhost supports APCu and Owncloud 8.2 urges you to enable it, it really boosts the website.
So I was curious, if Smarty would also support this. And it does.
I'm just not quite sure where to implement it.

Specs are as follows:
- Smarty 3.1.24 on CMSMS 1.12.1
- PHP 5.6.14
- APCu Support 4.0.7
apc.enabled On
apc.shm_size 32M
apc.writable /tmp

Re: How to use APC PHP-cache for Smarty 3.x in CMSMS?

Posted: Mon Nov 09, 2015 3:16 pm
by calguy1000
a: it is against forum rules to discuss hacking CMSMS. Because it tends to cause more problems than it solves.

b: You are already running a hacked version of CMSMS, so are ineligible for support. (we do not distribute Smarty 3.1.24).

Re: How to use APC PHP-cache for Smarty 3.x in CMSMS?

Posted: Tue Nov 10, 2015 9:01 am
by swgreed
I wasn't aware of "hacking" CMSMS (which implies a rather negative annotation) but keeping a 3rd party module up to date.
According to the changelog, the .24 release would also improve performance (i.e. "quick win").
Smarty 3.1.24 has a LONG list of new features, bug fixes and improvements since 3.1.21 (22 and 23 were never released publicly.) Most notably, compiling speed has been improved by 30-40% over the last release!
This is the "Developers Discussion" board (not "Product Support"), therefore I was curious for your thoughts and opinions and a possible hint where to put the 2 lines of code, so I can test it on my behalf.

I am not demanding a problem to solve but what I'm asking for is acutally a possible enhancement maybe worthwile for everyone.

The Smarty thread I mentioned was from 2010 when Smarty 3.0.x was just released. It's not specific to 3.1.16 or 3.1.24. Switching back to Smarty 3.1.16 (to a "non-hacked" state) raises the same question as in posting #1.

Re: How to use APC PHP-cache for Smarty 3.x in CMSMS?

Posted: Tue Nov 10, 2015 2:45 pm
by Jo Morg
swgreed wrote:I wasn't aware of "hacking" CMSMS (which implies a rather negative annotation) but keeping a 3rd party module up to date.
According to the changelog, the .24 release would also improve performance (i.e. "quick win").
The libraries included in CMSMS are (with the exception of 3rd party modules in the modules folder that are not part of the installed package) considered as being part of the core, and are maintained as such. The Dev team has tested all the available versions of these libraries, and use only the ones that are considered stable to be used with CMSMS. We also may modify any of those libs to work better with each release of CMSMS. So there are reasons to use one version of a specific lib instead of a more recent one. And by updating any of the libraries by yourself you may be creating bigger problems than the ones you are trying to solve, and that is considered a hack.
swgreed wrote:The Smarty thread I mentioned was from 2010 when Smarty 3.0.x was just released. It's not specific to 3.1.16 or 3.1.24. Switching back to Smarty 3.1.16 (to a "non-hacked" state) raises the same question as in posting #1.
In practical terms all you need to know is on that topic, and there is no need to hack CMSMS in any way. There are several approaches possible, for instance with an UDT with those 2 lines of code being called by a "ContentPreCompile" event from the CMSMS core... I didn't test it but that should work as long as you add the plugin file to the plugins directory.
However I strongly recommend you to revert the Smarty lib to the original distributed library, otherwise you'll have issues that we won't be able to solve or assist you with.