apc.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php namespace Laravel\Session;
  2. class APC extends Driver {
  3. /**
  4. * The APC cache driver instance.
  5. *
  6. * @var Cache\APC
  7. */
  8. private $apc;
  9. /**
  10. * The session lifetime.
  11. *
  12. * @var int
  13. */
  14. private $lifetime;
  15. /**
  16. * Create a new APC session driver instance.
  17. *
  18. * @param Cache\APC $apc
  19. * @param int $lifetime
  20. * @return void
  21. */
  22. public function __construct(\Laravel\Cache\APC $apc, $lifetime)
  23. {
  24. $this->apc = $apc;
  25. $this->lifetime = $lifetime;
  26. }
  27. /**
  28. * Load a session by ID.
  29. *
  30. * The session will be retrieved from persistant storage and returned as an array.
  31. * The array contains the session ID, last activity UNIX timestamp, and session data.
  32. *
  33. * @param string $id
  34. * @return array
  35. */
  36. protected function load($id)
  37. {
  38. return $this->apc->get($id);
  39. }
  40. /**
  41. * Save the session to persistant storage.
  42. *
  43. * @return void
  44. */
  45. protected function save()
  46. {
  47. $this->apc->put($this->session['id'], $this->session, $this->lifetime);
  48. }
  49. /**
  50. * Delete the session from persistant storage.
  51. *
  52. * @return void
  53. */
  54. protected function delete()
  55. {
  56. $this->apc->forget($this->session['id']);
  57. }
  58. }