private static function fillFromDatabase() { $cacheID = "all_currencies"; self::$_allCurrencies = AF::cache()->get($cacheID); if (!self::$_allCurrencies) { $db = self::$_msql = SafeMySQL::getInstance(); $sql = "SELECT * FROM `currency`"; self::$_allCurrencies = $db->getInd('currency_id', $sql); AF::cache()->set($cacheID, self::$_allCurrencies); } }
public static function getHtmlInfo($db) { echo '<script>var count_sql_queries = "' . $db->getQueryCount() . '"</script>'; echo '<div class="service_info"><div class="container">'; echo '<div class="t1">'; $format = "Execution time: %f second."; printf($format, self::$ScriptTime); echo '<br>Sql queries: <span id="count_sql_queries">' . $db->getQueryCount() . '</span> '; $array = $db->getStats(); if ($array) { echo ' <a href="javascript:serviceInfoQuerysDiv()">Show querys</a></div>'; } echo '<div class="t2">'; echo 'Memory consumption: ' . number_format(self::$totalMemory, 0, '.', ',') . ' bytes<br>'; echo 'Peak memory usage: ' . number_format(self::$memoryPeak, 0, '.', ',') . ' bytes'; $cacheStat = AF::cache()->stats(); $pUse = ($cacheStat['cmd_get'] - $cacheStat['cmd_set']) * 100 / $cacheStat['cmd_get']; echo '</div><div class="t3">Use memcache: <b>' . round($pUse) . '% (' . $cacheStat['cmd_get'] . '/' . $cacheStat['cmd_set'] . ')</b><br><a href="javascript:serviceInfoCacheDiv()">Show memcache info</a></div>'; echo '<div class="service_info_querys" style="display:none;">'; if ($array) { $i = 1; foreach ($array as $value) { echo '<br>' . $i . '. Sql: <b>' . $value['query'] . '</b>. <br>Time: ' . $value['timer']; $i++; } } echo '<br><br><div class="ajax hide"><b>Ajax sql</b><div></div></div>'; echo '</div>'; echo '<div class="service_info_cache" style="display:none;">'; foreach ($cacheStat as $key => $value) { if (isset(self::$_cacheInfo[$key])) { echo '<br>' . self::$_cacheInfo[$key] . ': <b>' . $value . '</b>'; } } echo '</div></div>'; }
public function clearCache() { parent::clearCache(); AF::cache()->delete('all_users_by_user_id'); }
public function clearCache() { parent::clearCache(); AF::cache()->delete('all_gateways'); }
public function clearCache() { parent::clearCache(); //Clear all ip_md5() $array = AF::cache()->get('array_ip'); foreach ($array as $k => $v) { AF::cache()->delete($k); } AF::cache()->delete('array_ip'); }
public function clearCache() { parent::clearCache(); AF::cache()->delete('all_languages'); AF::cache()->delete('all_countries'); }
public function clearCache() { parent::clearCache(); $cacheID = 'distinct_event_types'; AF::cache()->delete($cacheID); }
public function clearCache() { parent::clearCache(); AF::cache()->delete('satets_by_state_name'); }
<?php @(include_once '../settings/autoload.php'); AF::cache()->flush(); echo 'done...';
public function findAllInArray($turn = false) { $result = null; if ($this->isCache) { $cacheID = $this->modelName . '_get_all_in_array'; $result = AF::cache()->get($cacheID); } if (!$result) { // hack for Templates class if ($this->modelName == 'template') { $sql = "SELECT template_id, template_name, body_subject\n\t\t\t\t\tFROM ?n\n\t\t\t\t\tORDER BY ?s DESC"; } else { $sql = "SELECT *\n\t\t\t\t\tFROM ?n\n\t\t\t\t\tORDER BY ?s DESC"; } $pks = $this->getPrimaryField(); if (!is_array($pks)) { $pks = array($pks); } $resultTemp = self::$_msql->getAll($sql, $this->tableName(), implode(',', $pks)); $result = array(); foreach ($resultTemp as $item) { $keysArray = array(); foreach ($pks as $k) { $keysArray[] = $item[$k]; } $key = implode('_', $keysArray); $result[$key] = $item; } if ($this->isCache) { $data = serialize($result); if (strlen($data) < 1000000) { AF::cache()->set($cacheID, $result); } } } if ($this->_isRestrictions) { $pks = $this->getPrimaryField(); if (is_array($pks)) { $pks = implode('_', $pks); } $f = AF::userAccess()->getRestrictionBySearch($pks); if ($f) { foreach ($result as $k => $v) { if (!in_array($k, $f[$pks])) { unset($result[$k]); } } } } return $turn ? array_reverse($result) : $result; }
public static function cache() { if (!self::$cache) { self::$cache = AFMemCache::getInstance(Config::get()->components->cache['host'], Config::get()->components->cache['port'], 0, Config::get()->prefix); } return self::$cache; }