SproutCMS

This is the code documentation for the SproutCMS project

source of /sprout/Helpers/Drivers/Cache/Eaccelerator.php

Copyright (C) 2017 Karmabunny Pty Ltd.

This file is a part of SproutCMS.

SproutCMS is free software: you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation, either
version 2 of the License, or (at your option) any later version.

For more information, visit <http://getsproutcms.com>.

This class was originally from Kohana 2.3.4
Copyright 2007-2008 Kohana Team
  1. <?php
  2. /**
  3.  * Copyright (C) 2017 Karmabunny Pty Ltd.
  4.  *
  5.  * This file is a part of SproutCMS.
  6.  *
  7.  * SproutCMS is free software: you can redistribute it and/or modify it under the terms
  8.  * of the GNU General Public License as published by the Free Software Foundation, either
  9.  * version 2 of the License, or (at your option) any later version.
  10.  *
  11.  * For more information, visit <http://getsproutcms.com>.
  12.  *
  13.  * This class was originally from Kohana 2.3.4
  14.  * Copyright 2007-2008 Kohana Team
  15.  */
  16. namespace Sprout\Helpers\Drivers\Cache;
  17.  
  18. use Kohana;
  19. use Kohana_Exception;
  20.  
  21. use Sprout\Helpers\Drivers\CacheDriver;
  22.  
  23.  
  24. /**
  25.  * Eaccelerator-based Cache driver.
  26.  */
  27. class Eaccelerator implements CacheDriver
  28. {
  29.  
  30. public function __construct()
  31. {
  32. if ( ! extension_loaded('eaccelerator'))
  33. throw new Kohana_Exception('cache.extension_not_loaded', 'eaccelerator');
  34. }
  35.  
  36. public function get($id)
  37. {
  38. return eaccelerator_get($id);
  39. }
  40.  
  41. public function find($tag)
  42. {
  43. Kohana::log('error', 'tags are unsupported by the eAccelerator driver');
  44.  
  45. return array();
  46. }
  47.  
  48. public function set($id, $data, array $tags = NULL, $lifetime)
  49. {
  50. if ( ! empty($tags))
  51. {
  52. Kohana::log('error', 'tags are unsupported by the eAccelerator driver');
  53. }
  54.  
  55. return eaccelerator_put($id, $data, $lifetime);
  56. }
  57.  
  58. public function delete($id, $tag = FALSE)
  59. {
  60. if ($tag === TRUE)
  61. {
  62. Kohana::log('error', 'tags are unsupported by the eAccelerator driver');
  63. return FALSE;
  64. }
  65. elseif ($id === TRUE)
  66. {
  67. return eaccelerator_clean();
  68. }
  69. else
  70. {
  71. return eaccelerator_rm($id);
  72. }
  73. }
  74.  
  75. public function deleteExpired()
  76. {
  77. eaccelerator_gc();
  78.  
  79. return TRUE;
  80. }
  81.  
  82. } // End Cache eAccelerator Driver
  83.