2011-09-14 20:16:13 -05:00
|
|
|
<?php namespace Laravel\Session\Drivers;
|
2011-06-08 23:45:08 -05:00
|
|
|
|
2012-02-28 10:06:53 -06:00
|
|
|
class Memcached extends Driver {
|
2011-06-08 23:45:08 -05:00
|
|
|
|
2011-08-25 22:53:05 -05:00
|
|
|
/**
|
|
|
|
|
* The Memcache cache driver instance.
|
|
|
|
|
*
|
2012-02-04 21:30:52 +00:00
|
|
|
* @var Laravel\Cache\Drivers\Memcached
|
2011-08-25 22:53:05 -05:00
|
|
|
*/
|
|
|
|
|
private $memcached;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Create a new Memcached session driver instance.
|
|
|
|
|
*
|
2012-02-04 21:30:52 +00:00
|
|
|
* @param Laravel\Cache\Drivers\Memcached $memcached
|
2011-08-25 22:53:05 -05:00
|
|
|
* @return void
|
|
|
|
|
*/
|
2011-09-14 20:16:13 -05:00
|
|
|
public function __construct(\Laravel\Cache\Drivers\Memcached $memcached)
|
2011-08-25 22:53:05 -05:00
|
|
|
{
|
|
|
|
|
$this->memcached = $memcached;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2011-09-15 20:23:30 -05:00
|
|
|
* Load a session from storage by a given ID.
|
2011-08-25 22:53:05 -05:00
|
|
|
*
|
2011-09-15 20:23:30 -05:00
|
|
|
* If no session is found for the ID, null will be returned.
|
2011-09-14 23:54:14 -05:00
|
|
|
*
|
2011-08-25 22:53:05 -05:00
|
|
|
* @param string $id
|
|
|
|
|
* @return array
|
|
|
|
|
*/
|
2011-09-15 20:23:30 -05:00
|
|
|
public function load($id)
|
2011-06-08 23:45:08 -05:00
|
|
|
{
|
2011-08-25 22:53:05 -05:00
|
|
|
return $this->memcached->get($id);
|
2011-06-08 23:45:08 -05:00
|
|
|
}
|
|
|
|
|
|
2011-08-25 22:53:05 -05:00
|
|
|
/**
|
2011-09-15 20:23:30 -05:00
|
|
|
* Save a given session to storage.
|
2011-08-25 22:53:05 -05:00
|
|
|
*
|
2011-09-14 23:54:14 -05:00
|
|
|
* @param array $session
|
2011-09-15 20:23:30 -05:00
|
|
|
* @param array $config
|
2011-09-29 21:22:48 -05:00
|
|
|
* @param bool $exists
|
2011-08-25 22:53:05 -05:00
|
|
|
* @return void
|
|
|
|
|
*/
|
2011-09-29 21:22:48 -05:00
|
|
|
public function save($session, $config, $exists)
|
2011-06-08 23:45:08 -05:00
|
|
|
{
|
2011-09-15 20:23:30 -05:00
|
|
|
$this->memcached->put($session['id'], $session, $config['lifetime']);
|
2011-06-08 23:45:08 -05:00
|
|
|
}
|
|
|
|
|
|
2011-08-25 22:53:05 -05:00
|
|
|
/**
|
2011-09-15 20:23:30 -05:00
|
|
|
* Delete a session from storage by a given ID.
|
2011-08-25 22:53:05 -05:00
|
|
|
*
|
2011-09-14 23:54:14 -05:00
|
|
|
* @param string $id
|
2011-08-25 22:53:05 -05:00
|
|
|
* @return void
|
|
|
|
|
*/
|
2011-09-15 20:23:30 -05:00
|
|
|
public function delete($id)
|
2011-06-08 23:45:08 -05:00
|
|
|
{
|
2011-09-14 23:54:14 -05:00
|
|
|
$this->memcached->forget($id);
|
2011-06-08 23:45:08 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|