1: <?php namespace Laravel\Session\Drivers;
2:
3: class Memcached extends Driver {
4:
5: /**
6: * The Memcache cache driver instance.
7: *
8: * @var Laravel\Cache\Drivers\Memcached
9: */
10: private $memcached;
11:
12: /**
13: * Create a new Memcached session driver instance.
14: *
15: * @param Laravel\Cache\Drivers\Memcached $memcached
16: * @return void
17: */
18: public function __construct(\Laravel\Cache\Drivers\Memcached $memcached)
19: {
20: $this->memcached = $memcached;
21: }
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->memcached->get($id);
34: }
35:
36: /**
37: * Save a given session to storage.
38: *
39: * @param array $session
40: * @param array $config
41: * @param bool $exists
42: * @return void
43: */
44: public function save($session, $config, $exists)
45: {
46: $this->memcached->put($session['id'], $session, $config['lifetime']);
47: }
48:
49: /**
50: * Delete a session from storage by a given ID.
51: *
52: * @param string $id
53: * @return void
54: */
55: public function delete($id)
56: {
57: $this->memcached->forget($id);
58: }
59:
60: }