1: <?php namespace Laravel\Session\Drivers;
2:
3: class Redis extends Driver {
4:
5: /**
6: * The Redis cache driver instance.
7: *
8: * @var Laravel\Cache\Drivers\Redis
9: */
10: protected $redis;
11:
12: /**
13: * Create a new Redis session driver.
14: *
15: * @param Laravel\Cache\Drivers\Redis $redis
16: * @return void
17: */
18: public function __construct(\Laravel\Cache\Drivers\Redis $redis)
19: {
20: $this->redis = $redis;
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->redis->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->redis->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->redis->forget($id);
58: }
59:
60: }