当前位置: 首页>>代码示例>>PHP>>正文


PHP CRM_Core_BAO_PrevNextCache::cleanupCache方法代码示例

本文整理汇总了PHP中CRM_Core_BAO_PrevNextCache::cleanupCache方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_BAO_PrevNextCache::cleanupCache方法的具体用法?PHP CRM_Core_BAO_PrevNextCache::cleanupCache怎么用?PHP CRM_Core_BAO_PrevNextCache::cleanupCache使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CRM_Core_BAO_PrevNextCache的用法示例。


在下文中一共展示了CRM_Core_BAO_PrevNextCache::cleanupCache方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: cleanup

 /**
  * Do periodic cleanup of the CiviCRM session table.
  *
  * Also delete all session cache entries which are a couple of days old.
  * This keeps the session cache to a manageable size
  *
  * @param bool $session
  * @param bool $table
  * @param bool $prevNext
  */
 public static function cleanup($session = FALSE, $table = FALSE, $prevNext = FALSE)
 {
     // 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 && !$table && !$prevNext) {
         return;
     }
     if ($prevNext) {
         // delete all PrevNext caches
         CRM_Core_BAO_PrevNextCache::cleanupCache();
     }
     if ($table) {
         CRM_Core_Config::clearTempTables($timeIntervalDays . ' day');
     }
     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 = "\nDELETE FROM civicrm_cache\nWHERE       group_name = 'CiviCRM Session'\nAND         created_date <= %1\nAND         (" . implode(' OR ', $where) . ")";
         CRM_Core_DAO::executeQuery($sql, $params);
         $sql = "\nDELETE FROM civicrm_cache\nWHERE       group_name = 'CiviCRM Session'\nAND         created_date < date_sub( NOW( ), INTERVAL {$timeIntervalDays} DAY )\n";
         CRM_Core_DAO::executeQuery($sql);
     }
 }
开发者ID:hyebahi,项目名称:civicrm-core,代码行数:45,代码来源:Cache.php

示例2: cleanup

 /**
  * Do periodic cleanup of the CiviCRM session table. Also delete all session cache entries
  * which are a couple of days old. This keeps the session cache to a manageable size
  *
  * @return void
  * @static
  * @access private
  */
 static function cleanup($session = false, $table = false, $prevNext = false)
 {
     // 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 && !$table && !$prevNext) {
         return;
     }
     if ($prevNext) {
         // delete all PrevNext caches
         CRM_Core_BAO_PrevNextCache::cleanupCache();
     }
     if ($table) {
         // also delete all the action temp tables
         // that were created the same interval ago
         $dao = new CRM_Core_DAO();
         $query = "\nSELECT TABLE_NAME as tableName\nFROM   INFORMATION_SCHEMA.TABLES\nWHERE  TABLE_SCHEMA = %1\nAND    ( TABLE_NAME LIKE 'civicrm_task_action_temp_%'\n OR      TABLE_NAME LIKE 'civicrm_export_temp_%'\n OR      TABLE_NAME LIKE 'civicrm_import_job_%' )\nAND    CREATE_TIME < date_sub( NOW( ), INTERVAL {$timeIntervalDays} day )\n";
         $params = array(1 => array($dao->database(), 'String'));
         $tableDAO = CRM_Core_DAO::executeQuery($query, $params);
         $tables = array();
         while ($tableDAO->fetch()) {
             $tables[] = $tableDAO->tableName;
         }
         if (!empty($tables)) {
             $table = implode(',', $tables);
             // drop leftover temporary tables
             CRM_Core_DAO::executeQuery("DROP TABLE {$table}");
         }
     }
     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 %' . sizeof($params);
         }
         $sql = "\nDELETE FROM civicrm_cache\nWHERE       group_name = 'CiviCRM Session'\nAND         created_date <= %1\nAND         (" . implode(' OR ', $where) . ")";
         CRM_Core_DAO::executeQuery($sql, $params);
         $sql = "\nDELETE FROM civicrm_cache\nWHERE       group_name = 'CiviCRM Session'\nAND         created_date < date_sub( NOW( ), INTERVAL {$timeIntervalDays} DAY )\n";
         CRM_Core_DAO::executeQuery($sql);
     }
 }
开发者ID:hguru,项目名称:224Civi,代码行数:57,代码来源:Cache.php


注:本文中的CRM_Core_BAO_PrevNextCache::cleanupCache方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。