Symfony\Component\PropertyAccess\PropertyAccessor::createCache PHP Method

createCache() public static method

Creates the APCu adapter if applicable.
public static createCache ( string $namespace, integer $defaultLifetime, string $version, Psr\Log\LoggerInterface $logger = null ) : Symfony\Component\Cache\Adapter\AdapterInterface
$namespace string
$defaultLifetime integer
$version string
$logger Psr\Log\LoggerInterface
return Symfony\Component\Cache\Adapter\AdapterInterface
    public static function createCache($namespace, $defaultLifetime, $version, LoggerInterface $logger = null)
    {
        if (!class_exists('Symfony\Component\Cache\Adapter\ApcuAdapter')) {
            throw new \RuntimeException(sprintf('The Symfony Cache component must be installed to use %s().', __METHOD__));
        }

        if (!ApcuAdapter::isSupported()) {
            return new NullAdapter();
        }

        $apcu = new ApcuAdapter($namespace, $defaultLifetime / 5, $version);
        if (null !== $logger) {
            $apcu->setLogger($logger);
        }

        return $apcu;
    }

Usage Example

 /**
  * Gets the 'property_accessor' service.
  *
  * This service is shared.
  * This method always returns the same instance of the service.
  *
  * @return \Symfony\Component\PropertyAccess\PropertyAccessor A Symfony\Component\PropertyAccess\PropertyAccessor instance
  */
 protected function getPropertyAccessorService()
 {
     return $this->services['property_accessor'] = new \Symfony\Component\PropertyAccess\PropertyAccessor(false, false, \Symfony\Component\PropertyAccess\PropertyAccessor::createCache('lZoWmNUExf', NULL, 'kYH8hP4PfdP8SU3P7jSqTZ', $this->get('monolog.logger.cache', ContainerInterface::NULL_ON_INVALID_REFERENCE)));
 }
All Usage Examples Of Symfony\Component\PropertyAccess\PropertyAccessor::createCache