library/smarty/demo/plugins/cacheresource.pdo_gzip.php
changeset 46 f11c31f7fa3e
parent 45 a56e7f9a0463
child 47 03388ec805b4
equal deleted inserted replaced
45:a56e7f9a0463 46:f11c31f7fa3e
     1 <?php
       
     2 
       
     3 /**
       
     4  * PDO Cache Handler with GZIP support
       
     5  * Example usage :
       
     6  *      $cnx    =   new PDO("mysql:host=localhost;dbname=mydb", "username", "password");
       
     7  *      $smarty->setCachingType('pdo_gzip');
       
     8  *      $smarty->loadPlugin('Smarty_CacheResource_Pdo_Gzip');
       
     9  *      $smarty->registerCacheResource('pdo_gzip', new Smarty_CacheResource_Pdo_Gzip($cnx, 'smarty_cache'));
       
    10  *
       
    11  * @require Smarty_CacheResource_Pdo class
       
    12  * @author  Beno!t POLASZEK - 2014
       
    13  */
       
    14 require_once 'cacheresource.pdo.php';
       
    15 
       
    16 class Smarty_CacheResource_Pdo_Gzip extends Smarty_CacheResource_Pdo {
       
    17 
       
    18     /* 
       
    19      * Encodes the content before saving to database 
       
    20      * 
       
    21      * @param string $content 
       
    22      * @return string $content 
       
    23      * @access protected 
       
    24      */
       
    25     protected function inputContent($content) {
       
    26         return gzdeflate($content);
       
    27     }
       
    28 
       
    29     /* 
       
    30      * Decodes the content before saving to database 
       
    31      * 
       
    32      * @param string $content 
       
    33      * @return string $content 
       
    34      * @access protected 
       
    35      */
       
    36     protected function outputContent($content) {
       
    37         return gzinflate($content);
       
    38     }
       
    39 } 
       
    40