Add $config['sessions']['gc_limit'] to limit how much work we do in each session GC; defaulting to killing 1000 sessions at a time.

This commit is contained in:
Brion Vibber 2011-01-27 12:07:29 -08:00
parent 73011e6344
commit 433ec21119
2 changed files with 10 additions and 2 deletions

View File

@ -156,6 +156,13 @@ class Session extends Memcached_DataObject
$session->selectAdd(); $session->selectAdd();
$session->selectAdd('id'); $session->selectAdd('id');
$limit = common_config('sessions', 'gc_limit');
if ($limit > 0) {
// On large sites, too many sessions to expire
// at once will just result in failure.
$session->limit($limit);
}
$session->find(); $session->find();
while ($session->fetch()) { while ($session->fetch()) {

View File

@ -262,7 +262,8 @@ $default =
array('type' => 'fulltext'), array('type' => 'fulltext'),
'sessions' => 'sessions' =>
array('handle' => false, // whether to handle sessions ourselves array('handle' => false, // whether to handle sessions ourselves
'debug' => false), // debugging output for sessions 'debug' => false, // debugging output for sessions
'gc_limit' => 1000), // max sessions to expire at a time
'design' => 'design' =>
array('backgroundcolor' => null, // null -> 'use theme default' array('backgroundcolor' => null, // null -> 'use theme default'
'contentcolor' => null, 'contentcolor' => null,