diff --git a/application/config/session.php b/application/config/session.php index 8a18cfce..be0e3e0d 100644 --- a/application/config/session.php +++ b/application/config/session.php @@ -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'. | */ diff --git a/system/session/driver/apc.php b/system/session/driver/apc.php new file mode 100644 index 00000000..d240d015 --- /dev/null +++ b/system/session/driver/apc.php @@ -0,0 +1,49 @@ +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. + } + +} \ No newline at end of file diff --git a/system/session/factory.php b/system/session/factory.php index be0efa38..822cd074 100644 --- a/system/session/factory.php +++ b/system/session/factory.php @@ -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."); }