apc.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php namespace Laravel\Session\Drivers;
  2. class APC implements Driver {
  3. /**
  4. * The APC cache driver instance.
  5. *
  6. * This session driver relies on the APC cache driver to provide an interface for
  7. * working with an APC equipped server. The cache driver will provide all of the
  8. * functionality for retrieving and storing items in APC.
  9. *
  10. * @var Cache\Drivers\APC
  11. */
  12. private $apc;
  13. /**
  14. * Create a new APC session driver instance.
  15. *
  16. * @param Cache\Drivers\APC $apc
  17. * @return void
  18. */
  19. public function __construct(\Laravel\Cache\Drivers\APC $apc)
  20. {
  21. $this->apc = $apc;
  22. }
  23. /**
  24. * Load a session from storage by a given ID.
  25. *
  26. * If no session is found for the ID, null will be returned.
  27. *
  28. * @param string $id
  29. * @return array
  30. */
  31. public function load($id)
  32. {
  33. return $this->apc->get($id);
  34. }
  35. /**
  36. * Save a given session to storage.
  37. *
  38. * @param array $session
  39. * @param array $config
  40. * @return void
  41. */
  42. public function save($session, $config)
  43. {
  44. $this->apc->put($session['id'], $session, $config['lifetime']);
  45. }
  46. /**
  47. * Delete a session from storage by a given ID.
  48. *
  49. * @param string $id
  50. * @return void
  51. */
  52. public function delete($id)
  53. {
  54. $this->apc->forget($id);
  55. }
  56. }