Back to Factory class

Method getCache

public static \Joomla\CMS\Cache\CacheController
getCache
(mixed $group = '', mixed $handler = 'callback', mixed $storage = null)
Get a cache object
Parameters
  • string $group The cache group name
  • string $handler The handler to use
  • string $storage The storage method
Returns
  • \Joomla\CMS\Cache\CacheController object
Since
  • 1.7.0
Deprecated
  • 5.0
-
  • \Joomla\CMS\Cache\Cache
Class: Factory
Project: Joomla

Method getCache - Source code

/**
 * Get a cache object
 *
 * Returns the global {@link CacheController} object
 *
 * @param   string  $group    The cache group name
 * @param   string  $handler  The handler to use
 * @param   string  $storage  The storage method
 *
 * @return  \Joomla\CMS\Cache\CacheController object
 *
 * @see         Cache
 * @since       1.7.0
 * @deprecated  5.0 Use the cache controller factory instead
 */
public static function getCache($group = '', $handler = 'callback', $storage = null)
{
    @trigger_error(sprintf('%s() is deprecated. The cache controller should be fetched from the factory.', __METHOD__), E_USER_DEPRECATED);
    $hash = md5($group . $handler . $storage);
    if (isset(self::$cache[$hash])) {
        return self::$cache[$hash];
    }
    $handler = $handler === 'function' ? 'callback' : $handler;
    $options = array('defaultgroup' => $group);
    if (isset($storage)) {
        $options['storage'] = $storage;
    }
    $cache = self::getContainer()->get(CacheControllerFactoryInterface::class)->createCacheController($handler, $options);
    self::$cache[$hash] = $cache;
    return self::$cache[$hash];
}