Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.

Turck MMCache cache handler
Goto page Previous  1, 2, 3  Next
 
Post new topic   Reply to topic    Smarty Forum Index -> Tips and Tricks
View previous topic :: View next topic  
Author Message
OpenMacNews
Smarty Rookie


Joined: 03 Aug 2004
Posts: 34
Location: Floating on Io's Methane Seas ...

PostPosted: Thu May 04, 2006 7:46 am    Post subject: Reply with quote

hi boots,

boots wrote:

no, it is not autoloaded. You load the function(s) manually and configure Smarty to use it as the cache handler as described in the comments of the code:
[php:1:82bdfbd9b5]$smarty = new Smarty;
$smarty->cache_handler_func = 'smarty_cache_eaccelerator';
$smarty->caching = true;
$smarty->display('index.tpl');
[/php:1:82bdfbd9b5]
http://smarty.php.net/manual/en/section.template.cache.handler.func.php


(1) thank you, again.
(2) isn't it, like, ya know, 4 am there? yikes! ;-p


richard
Back to top
View user's profile Send private message
OpenMacNews
Smarty Rookie


Joined: 03 Aug 2004
Posts: 34
Location: Floating on Io's Methane Seas ...

PostPosted: Thu May 04, 2006 7:51 am    Post subject: Reply with quote

boots wrote:
$smarty->cache_handler_func = 'smarty_cache_eaccelerator';


at first attempt with this enabled, i *do* get page display, but with a couple of warning, not errors:

call_user_func_array() [function.call-user-func-array]: First argument is expected to be a valid callback, 'smarty_cache_eaccelerator' was given in /path/to/smarty/libs/internals/core.read_cache_file.php on line 38

Warning: call_user_func_array() [function.call-user-func-array]: First argument is expected to be a valid callback, 'smarty_cache_eaccelerator' was given in /path/to/smarty/libs/internals/core.write_cache_file.php on line 71

i presume this is still a concern ...

richard
Back to top
View user's profile Send private message
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Thu May 04, 2006 7:59 am    Post subject: Reply with quote

If you are using the code from the wiki and you have the code already loaded when you start Smarty, it should work -- not?
Back to top
View user's profile Send private message
OpenMacNews
Smarty Rookie


Joined: 03 Aug 2004
Posts: 34
Location: Floating on Io's Methane Seas ...

PostPosted: Thu May 04, 2006 8:08 am    Post subject: Reply with quote

boots wrote:
If you are using the code from the wiki


i am

boots wrote:
and you have the code already loaded when you start Smarty


i'm being dense. what code do you mean?

plugins/cache.eaccelerator.php?

i though that that is loaded BY smarty. no?
Back to top
View user's profile Send private message
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Thu May 04, 2006 3:48 pm    Post subject: Reply with quote

OpenMacNews wrote:
boots wrote:
and you have the code already loaded when you start Smarty


i'm being dense. what code do you mean?

plugins/cache.eaccelerator.php?

i though that that is loaded BY smarty. no?


The code I mean s the cache.eaccelerator.php code, of course and no, it is not loaded by Smarty. That's why I answered earlier that it is not autoloaded, that you have to manually load the code and that the code has to be loaded before you call Smarty. Think of it as a manually loaded plugin which is similar in that you have to do the loading yourself -- except cache handlers are not considered as part of the plugin system, per se.
Back to top
View user's profile Send private message
OpenMacNews
Smarty Rookie


Joined: 03 Aug 2004
Posts: 34
Location: Floating on Io's Methane Seas ...

PostPosted: Thu May 04, 2006 4:08 pm    Post subject: Reply with quote

g'mornin!

[quote="boots"]
OpenMacNews wrote:

i'm being dense ...



(note to self. do NOT work late at night after *any* beer .... check.) 8-{

ok. so after moving 'cache.eaccelerator.php' to my include path, & ensuring

Code:
...
require('cache.eaccelerator.php');
$smarty = new Smarty();
$smarty->cache_handler_func = 'smarty_cache_eaccelerator';
$smarty->caching = true;
...


i no longer see the previous warnings, but i now see in browser:

Code:
Warning: Smarty error: cache_handler: PHP Extension "eaccelerator" (http://eaccelerator.net/HomeUk) not installed. in /path/to/smarty/libs/Smarty.class.php on line 1095

Warning: Smarty error: cache_handler: PHP Extension "eaccelerator" (http://eaccelerator.net/HomeUk) not installed. in /path/to/smarty/libs/Smarty.class.php on line 1095



checking, i've:

Code:
% php -i | grep -i eaccelerator
    with eAccelerator v0.9.5-beta2, Copyright (c) 2004-2006 eAccelerator, by eAccelerator
eAccelerator
eAccelerator support => enabled
...


thx,

richard
Back to top
View user's profile Send private message
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Thu May 04, 2006 4:10 pm    Post subject: Reply with quote

Either the check being used to test for eaccelerator is no longer valid or your CLI and web environments are setup differently. Either way, I don't have eaccelerator installed and can't debug it myself. Can you investigate? Thanks!
Back to top
View user's profile Send private message
OpenMacNews
Smarty Rookie


Joined: 03 Aug 2004
Posts: 34
Location: Floating on Io's Methane Seas ...

PostPosted: Thu May 04, 2006 4:33 pm    Post subject: Reply with quote

boots wrote:
Can you investigate?


sure Smile

working on it ...
Back to top
View user's profile Send private message
OpenMacNews
Smarty Rookie


Joined: 03 Aug 2004
Posts: 34
Location: Floating on Io's Methane Seas ...

PostPosted: Thu May 04, 2006 11:32 pm    Post subject: Reply with quote

boots wrote:
Can you investigate?


well, it seems this is an issue that the api has changed and *not* insignificantly.

from the eAccelerator developer (Bart, 'zoeloelip') ...

Quote:
That very ugly webui has been removed and replaced with a whole set of function to reproduce this in a php script. You should check on the functions your program needs. I guess this is eaccelerator_get. Btw, these function have been disabled by default Smile

You can find the api docs on this website:
http://bart.eaccelerator.net/doc/phpdoc/


simply changing:

Code:
-    if(!function_exists("eaccelerator")) {
+    if(!function_exists("eaccelerator_get")) {


prevents the appearance of the 'warning', but the page executes 'blank', and 'brutally' kills off an apache child:

Code:
[Thu May 04 16:41:07 2006] [notice] child pid 21961 exit signal Bus error (10)


this looks like it'll need some fixin' ...


richard
Back to top
View user's profile Send private message
OpenMacNews
Smarty Rookie


Joined: 03 Aug 2004
Posts: 34
Location: Floating on Io's Methane Seas ...

PostPosted: Fri May 05, 2006 12:00 am    Post subject: Reply with quote

one more thing ...

fwiw, iiuc:

"old api" in eAccelerator version <= v0.94.x
compatible with php 4.x & 5.0.x

"new api" in eA, version >= 0.95.x & svn trunk
compatible with php 5.1.x
Back to top
View user's profile Send private message
brettz9
Smarty Regular


Joined: 07 Jul 2006
Posts: 93

PostPosted: Sun Jul 09, 2006 2:53 am    Post subject: Reply with quote

OpenMacNews, I guess you didn't find a fix for this then?

Brett
Back to top
View user's profile Send private message
mapletip
Smarty n00b


Joined: 22 Oct 2006
Posts: 2

PostPosted: Sun Nov 05, 2006 10:27 pm    Post subject: Reply with quote

Notice: unserialize() [function.unserialize]: Error at offset 0 of 3 bytes in cache.eaccelerator.php on line 45

To fix the eaccelerator not installed, configure with --with-eaccelerator-shared-memory
Back to top
View user's profile Send private message
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Mon Nov 06, 2006 5:02 pm    Post subject: Reply with quote

mapletip wrote:
Notice: unserialize() [function.unserialize]: Error at offset 0 of 3 bytes in cache.eaccelerator.php on line 45

To fix the eaccelerator not installed, configure with --with-eaccelerator-shared-memory


Yes, mapletip has it right. Since something like 0.9.4 The shared-memory interface is turned-off in default builds. Check the eAccelerator site for more details.
Back to top
View user's profile Send private message
d2kagw
Smarty n00b


Joined: 25 Jul 2006
Posts: 2

PostPosted: Sun Mar 18, 2007 11:49 pm    Post subject: Reply with quote

Hi all,

Great plugin, we use it heaps on our site.
Just wondering though, is there anyway to pass in variables??

like
Code:

{clipcache id=test group=foo ttl=5 userName="XXX"}
    hello, my name is {$userName} and the time is {$smarty.now}
{/clipcache}


Question

CHEERS![/code]
Back to top
View user's profile Send private message
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Mon Mar 19, 2007 5:43 pm    Post subject: Reply with quote

Hi.

Not explicitly. All variables come from the calling scope.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Smarty Forum Index -> Tips and Tricks All times are GMT
Goto page Previous  1, 2, 3  Next
Page 2 of 3

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP