memory_driver_apc.php 993 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. /**
  3. * [Discuz!] (C)2001-2099 Comsenz Inc.
  4. * This is NOT a freeware, use is subject to license terms
  5. *
  6. * $Id: memory_driver_apc.php 27635 2012-02-08 06:38:31Z zhangguosheng $
  7. */
  8. if (!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. class memory_driver_apc {
  12. public $cacheName = 'APC';
  13. public $enable;
  14. public function env() {
  15. return function_exists('apc_cache_info') && @apc_cache_info();
  16. }
  17. public function init($config) {
  18. $this->enable = $this->env();
  19. }
  20. public function get($key) {
  21. return apc_fetch($key);
  22. }
  23. public function set($key, $value, $ttl = 0) {
  24. return apc_store($key, $value, $ttl);
  25. }
  26. public function rm($key) {
  27. return apc_delete($key);
  28. }
  29. public function clear() {
  30. return apc_clear_cache('user');
  31. }
  32. public function inc($key, $step = 1) {
  33. return apc_inc($key, $step) !== false ? apc_fetch($key) : false;
  34. }
  35. public function dec($key, $step = 1) {
  36. return apc_dec($key, $step) !== false ? apc_fetch($key) : false;
  37. }
  38. }