added apc session driver.
This commit is contained in:
parent
24c2344ae4
commit
3b63335c95
|
@ -12,7 +12,7 @@
|
||||||
| Since HTTP is stateless, sessions are used to maintain "state" across
|
| Since HTTP is stateless, sessions are used to maintain "state" across
|
||||||
| multiple requests from the same user of your application.
|
| multiple requests from the same user of your application.
|
||||||
|
|
|
|
||||||
| Supported Drivers: 'file', 'db', 'memcached'.
|
| Supported Drivers: 'file', 'db', 'memcached', 'apc'.
|
||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
@ -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.
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -21,6 +21,9 @@ public static function make($driver)
|
||||||
case 'memcached':
|
case 'memcached':
|
||||||
return new Driver\Memcached;
|
return new Driver\Memcached;
|
||||||
|
|
||||||
|
case 'apc':
|
||||||
|
return new Driver\APC;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw new \Exception("Session driver [$driver] is not supported.");
|
throw new \Exception("Session driver [$driver] is not supported.");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue