memcached.php 834 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php namespace System\Session;
  2. use System\Cache;
  3. use System\Config;
  4. class Memcached implements Driver {
  5. /**
  6. * Load a session by ID.
  7. *
  8. * @param string $id
  9. * @return array
  10. */
  11. public function load($id)
  12. {
  13. return Cache::driver('memcached')->get($id);
  14. }
  15. /**
  16. * Save a session.
  17. *
  18. * @param array $session
  19. * @return void
  20. */
  21. public function save($session)
  22. {
  23. Cache::driver('memcached')->put($session['id'], $session, Config::get('session.lifetime'));
  24. }
  25. /**
  26. * Delete a session by ID.
  27. *
  28. * @param string $id
  29. * @return void
  30. */
  31. public function delete($id)
  32. {
  33. Cache::driver('memcached')->forget($id);
  34. }
  35. /**
  36. * Delete all expired sessions.
  37. *
  38. * @param int $expiration
  39. * @return void
  40. */
  41. public function sweep($expiration)
  42. {
  43. // Memcached sessions will expire automatically.
  44. }
  45. }