No Description

YacCache.php 565B

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. /**
  3. * yac实现cache
  4. */
  5. class YacCache implements iCache
  6. {
  7. public $isEnable = true;
  8. function __construct()
  9. {
  10. if (!extension_loaded("yac"))
  11. $this->isEnable = false;
  12. }
  13. public function getCache($key)
  14. {
  15. $key = md5($key);
  16. if($this->isEnable){
  17. $yac = new Yac();
  18. return $yac->get($key);
  19. }else{
  20. echo "yac is not enable ,skip getCache";
  21. }
  22. }
  23. public function setCache($key,$var)
  24. {
  25. $key = md5($key);
  26. if($this->isEnable){
  27. $yac = new Yac();
  28. $yac->set($key, $var);
  29. }else{
  30. echo "yac is not enable ,skip setCache";
  31. }
  32. }
  33. }
  34. ?>