added apc session driver.

This commit is contained in:
Taylor Otwell 2011-06-21 23:19:37 -05:00
parent 24c2344ae4
commit 3b63335c95
3 changed files with 53 additions and 1 deletions

View File

@ -12,7 +12,7 @@
| Since HTTP is stateless, sessions are used to maintain "state" across
| multiple requests from the same user of your application.
|
| Supported Drivers: 'file', 'db', 'memcached'.
| Supported Drivers: 'file', 'db', 'memcached', 'apc'.
|
*/

View File

@ -0,0 +1,49 @@
<?php namespace System\Session\Driver;
class APC implements \System\Session\Driver {
/**
* Load a session by ID.
*
* @param string $id
* @return array
*/
public function load($id)
{
return \System\Cache::driver('apc')->get($id);
}
/**
* Save a session.
*
* @param array $session
* @return void
*/
public function save($session)
{
\System\Cache::driver('apc')->put($session['id'], $session, \System\Config::get('session.lifetime'));
}
/**
* Delete a session by ID.
*
* @param string $id
* @return void
*/
public function delete($id)
{
\System\Cache::driver('apc')->forget($id);
}
/**
* Delete all expired sessions.
*
* @param int $expiration
* @return void
*/
public function sweep($expiration)
{
// APC sessions will expire automatically.
}
}

View File

@ -21,6 +21,9 @@ public static function make($driver)
case 'memcached':
return new Driver\Memcached;
case 'apc':
return new Driver\APC;
default:
throw new \Exception("Session driver [$driver] is not supported.");
}