CacheAdapterApc.php 869 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. class LtCacheAdapterApc implements LtCacheAdapter
  3. {
  4. public function connect($hostConf)
  5. {
  6. return true;
  7. }
  8. public function add($key, $value, $ttl = 0, $tableName, $connectionResource)
  9. {
  10. return apc_add($this->getRealKey($tableName, $key), $value, $ttl);
  11. }
  12. public function del($key, $tableName, $connectionResource)
  13. {
  14. return apc_delete($this->getRealKey($tableName, $key));
  15. }
  16. public function get($key, $tableName, $connectionResource)
  17. {
  18. return apc_fetch($this->getRealKey($tableName, $key));
  19. }
  20. public function update($key, $value, $ttl = 0, $tableName, $connectionResource)
  21. {
  22. if ($this->del($key, $tableName, $connectionResource))
  23. {
  24. return $this->add($key, $value, $ttl, $tableName, $connectionResource);
  25. }
  26. else
  27. {
  28. return false;
  29. }
  30. }
  31. protected function getRealKey($tableName, $key)
  32. {
  33. return $tableName . "-" . $key;
  34. }
  35. }