CacheRam.php 873 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. /** @package verysimple::Phreeze */
  3. /** import supporting libraries */
  4. require_once("ICache.php");
  5. /**
  6. * CacheRam is an implementation of a Cache that persists to ram for the current page load only
  7. *
  8. * @package verysimple::Phreeze
  9. * @author VerySimple Inc.
  10. * @copyright 1997-2008 VerySimple, Inc.
  11. * @license http://www.gnu.org/licenses/lgpl.html LGPL
  12. * @version 2.0
  13. */
  14. class CacheRam implements ICache
  15. {
  16. private $ram = array();
  17. public function Get($key,$flags=null)
  18. {
  19. return isset($this->ram[$key]) ? $this->ram[$key] : null;
  20. }
  21. public function GetKeys()
  22. {
  23. return array_keys($this->ram);
  24. }
  25. public function Set($key,$val,$flags=null,$timeout=null)
  26. {
  27. $this->ram[$key] = $val;
  28. }
  29. public function Delete($key)
  30. {
  31. if (isset($this->ram[$key])) unset($this->ram[$key]);
  32. }
  33. }
  34. ?>