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