*
* Also delete all session cache entries which are a couple of days old.
* This keeps the session cache to a manageable size
+ * Delete Contribution page session caches more energetically.
*
* @param bool $session
* @param bool $table
* @param bool $prevNext
*/
public static function cleanup($session = FALSE, $table = FALSE, $prevNext = FALSE) {
+ // first delete all sessions more than 20 minutes old which are related to any potential transaction
+ $timeIntervalMins = 20;
+ if (TRUE) {
+ $transactionPages = array(
+ 'CRM_Contribute_Controller_Contribution',
+ 'CRM_Event_Controller_Registration',
+ );
+
+ $params = array(
+ 1 => array(
+ date('Y-m-d H:i:s', time() - $timeIntervalMins * 60),
+ 'String',
+ ),
+ );
+ foreach ($transactionPages as $trPage) {
+ $params[] = array("%${trPage}%", 'String');
+ $where[] = 'path LIKE %' . count($params);
+ }
+
+ $sql = "
+DELETE FROM civicrm_cache
+WHERE group_name = 'CiviCRM Session'
+AND created_date <= %1
+AND (" . implode(' OR ', $where) . ")";
+ CRM_Core_DAO::executeQuery($sql, $params);
+ }
// clean up the session cache every $cacheCleanUpNumber probabilistically
$cleanUpNumber = 757;
// clean up all sessions older than $cacheTimeIntervalDays days
$timeIntervalDays = 2;
- $timeIntervalMins = 30;
if (mt_rand(1, 100000) % $cleanUpNumber == 0) {
$session = $table = $prevNext = TRUE;
}
if ($session) {
- // first delete all sessions which are related to any potential transaction
- // page
- $transactionPages = array(
- 'CRM_Contribute_Controller_Contribution',
- 'CRM_Event_Controller_Registration',
- );
-
- $params = array(
- 1 => array(
- date('Y-m-d H:i:s', time() - $timeIntervalMins * 60),
- 'String',
- ),
- );
- foreach ($transactionPages as $trPage) {
- $params[] = array("%${trPage}%", 'String');
- $where[] = 'path LIKE %' . count($params);
- }
-
- $sql = "
-DELETE FROM civicrm_cache
-WHERE group_name = 'CiviCRM Session'
-AND created_date <= %1
-AND (" . implode(' OR ', $where) . ")";
- CRM_Core_DAO::executeQuery($sql, $params);
$sql = "
DELETE FROM civicrm_cache