apc.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php namespace Laravel\Cache;
  2. use Laravel\Config;
  3. class APC extends Driver {
  4. /**
  5. * Determine if an item exists in the cache.
  6. *
  7. * <code>
  8. * // Determine if the "name" item exists in the cache
  9. * $exists = Cache::driver()->has('name');
  10. * </code>
  11. *
  12. * @param string $key
  13. * @return bool
  14. */
  15. public function has($key)
  16. {
  17. return ( ! is_null($this->get($key)));
  18. }
  19. /**
  20. * Retrieve an item from the cache driver.
  21. *
  22. * @param string $key
  23. * @return mixed
  24. */
  25. protected function retrieve($key)
  26. {
  27. return ( ! is_null($cache = apc_fetch(Config::get('cache.key').$key))) ? $cache : null;
  28. }
  29. /**
  30. * Write an item to the cache for a given number of minutes.
  31. *
  32. * <code>
  33. * // Write the "name" item to the cache for 30 minutes
  34. * Cache::driver()->put('name', 'Fred', 30);
  35. * </code>
  36. *
  37. * @param string $key
  38. * @param mixed $value
  39. * @param int $minutes
  40. * @return void
  41. */
  42. public function put($key, $value, $minutes)
  43. {
  44. apc_store(Config::get('cache.key').$key, $value, $minutes * 60);
  45. }
  46. /**
  47. * Delete an item from the cache.
  48. *
  49. * @param string $key
  50. * @return void
  51. */
  52. public function forget($key)
  53. {
  54. apc_delete(Config::get('cache.key').$key);
  55. }
  56. }