Contao\Cache::set PHP Метод

set() публичный статический Метод

Add a cache entry
public static set ( string $strKey, mixed $varValue )
$strKey string The cache key
$varValue mixed The data to be cached
    public static function set($strKey, $varValue)
    {
        static::$arrData[$strKey] = $varValue;
    }

Usage Example

Пример #1
0
 /**
  * Get the details of a page including inherited parameters
  *
  * @param mixed $intId A page ID or a Model object
  *
  * @return \PageModel The page model or null
  *
  * @deprecated Deprecated since Contao 4.0, to be removed in Contao 5.0.
  *             Use PageModel::findWithDetails() or PageModel->loadDetails() instead.
  */
 public static function getPageDetails($intId)
 {
     trigger_error('Using Controller::getPageDetails() has been deprecated and will no longer work in Contao 5.0. Use PageModel::findWithDetails() or PageModel->loadDetails() instead.', E_USER_DEPRECATED);
     if ($intId instanceof \PageModel) {
         return $intId->loadDetails();
     } elseif ($intId instanceof \Model\Collection) {
         /** @var \PageModel $objPage */
         $objPage = $intId->current();
         return $objPage->loadDetails();
     } elseif (is_object($intId)) {
         $strKey = __METHOD__ . '-' . $intId->id;
         // Try to load from cache
         if (\Cache::has($strKey)) {
             return \Cache::get($strKey);
         }
         // Create a model from the database result
         $objPage = new \PageModel();
         $objPage->setRow($intId->row());
         $objPage->loadDetails();
         \Cache::set($strKey, $objPage);
         return $objPage;
     } else {
         // Invalid ID
         if (!strlen($intId) || $intId < 1) {
             return null;
         }
         $strKey = __METHOD__ . '-' . $intId;
         // Try to load from cache
         if (\Cache::has($strKey)) {
             return \Cache::get($strKey);
         }
         $objPage = \PageModel::findWithDetails($intId);
         \Cache::set($strKey, $objPage);
         return $objPage;
     }
 }
All Usage Examples Of Contao\Cache::set