Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Cache resource and Compile cache at the same time.

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Smarty Development
View previous topic :: View next topic  
Author Message
kataxxx
Smarty Rookie


Joined: 08 Apr 2012
Posts: 10

PostPosted: Wed Oct 03, 2012 7:37 am    Post subject: Cache resource and Compile cache at the same time. Reply with quote

I've implemented those 2 resource with mongo. (Custom resources) and it works. One at a time!

If I have :
--$Smarty->display('template.html', $templade_id);
The resource cache works.

If I have:
--$Smarty->display('mongo:template.html', $templade_id);
The resource compile works.

Can't figure out what's wrong. I implemented all those functionalities.. I have to implement more?
Any idea? Here's my class methods that I use.

Code:
class Smarty_CacheResource_Mongo extends Smarty_CacheResource_Custom {
    // PDO instance
    protected $m;
   
   
    public function __construct();

    protected function fetch($id, $name, $cache_id, $compile_id, &$content, &$mtime);
   
    protected function fetchTimestamp($id, $name, $cache_id, $compile_id);
   
    protected function save($id, $name, $cache_id, $compile_id, $exp_time, $content);
   
   protected function delete($name, $cache_id, $compile_id, $exp_time);
}

class Smarty_Resource_Mongo extends Smarty_Resource_Custom {
   // mongo
   protected $m = null;
   
   public function __construct();
   
   protected function fetch($name, &$source, &$mtime);
   
   private function saveTemplate($tpl_name, $tpl_source);
   
   private function getTemplate($tpl_name);
   
   protected function fetchTimestamp($name);
   
   public function populate(Smarty_Template_Source $source, Smarty_Internal_Template $_template=null) {
          parent::populate($source, $_template);
          $source->recompiled = true;
       }
}

$Smarty->caching_type = 'mongo';
$Smarty->cache_lifetime = 2;
$Smarty->caching = true;
$Smarty->registerResource('mongo', new Smarty_Resource_Mongo());




Thank you!!!
Back to top
View user's profile Send private message
kataxxx
Smarty Rookie


Joined: 08 Apr 2012
Posts: 10

PostPosted: Thu Oct 11, 2012 2:30 pm    Post subject: Re: Cache resource and Compile cache at the same time. Reply with quote

May someone help me? I don't wanna use HDD/SSD for templates.
At least let me know if that's possible.

Thank you :)
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Smarty Development All times are GMT
Page 1 of 1

 
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