cache_get

Хочешь помочь с переводом? Это очень просто и быстро. Лишь зарегистрируйся, и можешь тут же начать переводить.

includes/cache.inc, строка 12

Версии
5 – 6
cache_get($key, $table = 'cache')

Возвращает данные из кэша. Данные могут быть сохранены в виде простого текста или в сериализованной данных. cache_get автоматически десериализирует массивы и объекты.

Параметры

$cid ID получаемых данных.

$table Таблица кеша, в которой хранятся данные (по-умолчанию, 'cache'). Возможны также 'cache_filter', 'cache_menu', 'cache_page' и др.

▾ 5 функции вызывают cache_get()

check_markup in modules/filter/filter.module
Фильтрует текст с помощью выбранного формата ввода.
locale in modules/locale/locale.module
Provides interface translation services.
menu_get_menu in includes/menu.inc
Return the menu data structure.
page_get_cache in includes/bootstrap.inc
Retrieve the current page from the cache.
variable_init in includes/bootstrap.inc
Загружает таблицу "постоянных" переменных.

Код

<?php
function cache_get($key, $table = 'cache') {
  global $user;

  // Garbage collection necessary when enforcing a minimum cache lifetime
  $cache_flush = variable_get('cache_flush', 0);
  if ($cache_flush && ($cache_flush + variable_get('cache_lifetime', 0) <= time())) {
    // Reset the variable immediately to prevent a meltdown in heavy load situations.
    variable_set('cache_flush', 0);
    // Time to flush old cache data
    db_query("DELETE FROM {". $table ."} WHERE expire != %d AND expire <= %d", CACHE_PERMANENT, $cache_flush);
  }

  $cache = db_fetch_object(db_query("SELECT data, created, headers, expire FROM {". $table ."} WHERE cid = '%s'", $key));
  if (isset($cache->data)) {
    // If the data is permanent or we're not enforcing a minimum cache lifetime
    // always return the cached data.
    if ($cache->expire == CACHE_PERMANENT || !variable_get('cache_lifetime', 0)) {
      $cache->data = db_decode_blob($cache->data);
    }
    // If enforcing a minimum cache lifetime, validate that the data is
    // currently valid for this user before we return it by making sure the
    // cache entry was created before the timestamp in the current session's
    // cache timer. The cache variable is loaded into the $user object by
    // sess_read() in session.inc.
    else {
      if ($user->cache > $cache->created) {
        // This cache data is too old and thus not valid for us, ignore it.
        return 0;
      }
      else {
        $cache->data = db_decode_blob($cache->data);
      }
    }
    return $cache;
  }
  return 0;
}
?>
Войдите или зарегистрируйтесь, чтобы получить возможность отправлять комментарии

Вход в систему