From 433ec211199aedc98e7d6949a17d6b5c2d0932f3 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Thu, 27 Jan 2011 12:07:29 -0800 Subject: [PATCH] Add $config['sessions']['gc_limit'] to limit how much work we do in each session GC; defaulting to killing 1000 sessions at a time. --- classes/Session.php | 7 +++++++ lib/default.php | 5 +++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/classes/Session.php b/classes/Session.php index e1c83ad4dc..166b89815a 100644 --- a/classes/Session.php +++ b/classes/Session.php @@ -156,6 +156,13 @@ class Session extends Memcached_DataObject $session->selectAdd(); $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(); while ($session->fetch()) { diff --git a/lib/default.php b/lib/default.php index 85d27f5220..4b28e3238b 100644 --- a/lib/default.php +++ b/lib/default.php @@ -261,8 +261,9 @@ $default = 'search' => array('type' => 'fulltext'), 'sessions' => - array('handle' => false, // whether to handle sessions ourselves - 'debug' => false), // debugging output for sessions + array('handle' => false, // whether to handle sessions ourselves + 'debug' => false, // debugging output for sessions + 'gc_limit' => 1000), // max sessions to expire at a time 'design' => array('backgroundcolor' => null, // null -> 'use theme default' 'contentcolor' => null,