*
* If not, regenerate, else return.
*
- * @param $groupIDs
+ * @param array $groupIDs
* Of group that we are checking against.
*
* @return bool
}
/**
- * Common function that formulates the query to see which groups needs to be refreshed
- * based on their cache date and the smartGroupCacheTimeOut
+ * Formulate the query to see which groups needs to be refreshed.
+ *
+ * The calculation is based on their cache date and the smartGroupCacheTimeOut
*
* @param string $groupIDClause
* The clause which limits which groups we need to evaluate.
}
/**
- * Checks to see if a group has been refreshed recently. This is primarily used
- * in a locking scenario when some other process might have refreshed things underneath
+ * Check to see if a group has been refreshed recently.
+ *
+ * This is primarily used in a locking scenario when some other process might have refreshed things underneath
* this process
*
* @param int $groupID
}
/**
- * Check to see if we have cache entries for this group
+ * Check to see if we have cache entries for this group.
+ *
* if not, regenerate, else return
*
- * @param int /array $groupIDs groupIDs of group that we are checking against
+ * @param int|array $groupIDs groupIDs of group that we are checking against
* if empty, all groups are checked
* @param int $limit
* Limits the number of groups we evaluate.
}
/**
- * FIXME: This function should not be needed, because the cache table should not be getting truncated
+ * Fill the group contact cache if it is empty.
+ *
+ * Do this by the expensive operation of loading all groups. Call sparingly.
*/
public static function fillIfEmpty() {
if (!CRM_Core_DAO::singleValueQuery("SELECT COUNT(id) FROM civicrm_group_contact_cache")) {
}
/**
+ * Build the smart group cache for a given group.
+ *
* @param int $groupID
*/
public static function add($groupID) {
}
/**
+ * Store values into the group contact cache.
+ *
+ * @todo review use of INSERT IGNORE. This function appears to be slower that inserting
+ * with a left join. Also, 200 at once seems too little.
+ *
* @param int $groupID
- * @param $values
+ * @param array $values
*/
public static function store(&$groupID, &$values) {
$processed = FALSE;
/**
* Removes all the cache entries pertaining to a specific group.
+ *
* If no groupID is passed in, removes cache entries for all groups
* Has an optimization to bypass repeated invocations of this function.
* Note that this function is an advisory, i.e. the removal respects the
}
/**
- * Removes one or more contacts from the smart group cache.
+ * Remove one or more contacts from the smart group cache.
+ *
* @param int|array $cid
* @param int $groupId
+ *
* @return bool
* TRUE if successful.
*/
}
/**
+ * Retrieve the smart group cache timeout in minutes.
+ *
+ * This checks if a timeout has been configured. If one has then smart groups should not
+ * be refreshed more frequently than the time out. If a group was recently refreshed it should not
+ * refresh again within that period.
+ *
* @return int
*/
public static function smartGroupCacheTimeout() {
return $config->smartGroupCacheTimeout;
}
- // lets have a min cache time of 5 mins if not set
+ // Default to 5 minutes.
return 5;
}
/**
* Get all the smart groups that this contact belongs to.
+ *
* Note that this could potentially be a super slow function since
* it ensure that all contact groups are loaded in the cache
*