本文整理汇总了PHP中Doctrine\Common\Cache\CacheProvider::setNamespace方法的典型用法代码示例。如果您正苦于以下问题:PHP CacheProvider::setNamespace方法的具体用法?PHP CacheProvider::setNamespace怎么用?PHP CacheProvider::setNamespace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\Common\Cache\CacheProvider
的用法示例。
在下文中一共展示了CacheProvider::setNamespace方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init
private function init($namespace)
{
$prefix = self::$namespacePrefix;
$namespace = "{$prefix}:{$namespace}";
$type = 0;
if (static::$TYPE_PREFER_DEFAULT == 0) {
if (isset(static::$_TYPE)) {
$type = static::$_TYPE;
} else {
$type = static::$TYPE_DEFAULT;
}
} else {
$type = static::$TYPE_PREFER_DEFAULT;
}
if ($type == static::$TYPE_APC) {
$this->_cacheImplement = new ApcCache();
} else {
if ($type == static::$TYPE_MEMCACHE) {
$m = new MemcacheCache();
$memcache = new \Memcache();
$memcache->connect('localhost', 11211);
$m->setMemcache($memcache);
$this->_cacheImplement = $m;
} else {
if ($type == static::$TYPE_XCACHE) {
$this->_cacheImplement = new XcacheCache();
} else {
$this->_cacheImplement = new ArrayCache();
}
}
}
$this->_cacheImplement->setNamespace($namespace);
}
示例2: __construct
/**
* @param string $name
* @param \Doctrine\Common\Cache\CacheProvider $cache
* @param integer $lifetime
*/
public function __construct($name, CacheProvider $cache, $lifetime = 0)
{
$this->cache = $cache;
$this->name = (string) $name;
$this->lifetime = (int) $lifetime;
$this->cache->setNamespace($this->name);
}
示例3: __construct
/**
* Constructor
*
* @param CacheProvider $cache
*/
public function __construct(CacheProvider $cache = null)
{
$this->cache = $cache;
if ($this->cache !== null && $this->cache->getNamespace() === '') {
$this->cache->setNamespace(self::CACHE_NAMESPACE);
}
}
示例4: __construct
/**
* @param ConfigProvider $securityConfigProvider
* @param ConfigProvider $entityConfigProvider
* @param CacheProvider|null $cache
*/
public function __construct(ConfigProvider $securityConfigProvider, ConfigProvider $entityConfigProvider, CacheProvider $cache = null)
{
$this->securityConfigProvider = $securityConfigProvider;
$this->entityConfigProvider = $entityConfigProvider;
$this->cache = $cache;
if ($this->cache !== null && $this->cache->getNamespace() === '') {
$this->cache->setNamespace(self::CACHE_NAMESPACE);
}
}
示例5: __construct
/**
* Constructor
*
* @param array $owningEntityNames
* @param ConfigProvider $configProvider
* @param EntityClassResolver $entityClassResolver
* @param CacheProvider|null $cache
*
* @SuppressWarnings(PHPMD.NPathComplexity)
*/
public function __construct(array $owningEntityNames, ConfigProvider $configProvider, EntityClassResolver $entityClassResolver = null, CacheProvider $cache = null)
{
$this->organizationClass = $entityClassResolver === null ? $owningEntityNames['organization'] : $entityClassResolver->getEntityClass($owningEntityNames['organization']);
$this->businessUnitClass = $entityClassResolver === null ? $owningEntityNames['business_unit'] : $entityClassResolver->getEntityClass($owningEntityNames['business_unit']);
$this->userClass = $entityClassResolver === null ? $owningEntityNames['user'] : $entityClassResolver->getEntityClass($owningEntityNames['user']);
$this->configProvider = $configProvider;
$this->cache = $cache;
if ($this->cache !== null && $this->cache->getNamespace() === '') {
$this->cache->setNamespace(self::CACHE_NAMESPACE);
}
$this->noOwnershipMetadata = new OwnershipMetadata();
}
示例6: __construct
/**
* @param string $type
* @param string $namespace
*
* @throws \InvalidArgumentException
* @internal param string $storeId
*/
public function __construct($type = CacheTypes::ARRAY_CACHE, $namespace = null)
{
if (!CacheTypes::contains($type)) {
throw new \InvalidArgumentException('The $type "' . $type . '" is not valid.');
}
$_class = static::STORE_NAMESPACE . $type . 'Cache';
$_mirror = new \ReflectionClass($_class);
$this->_store = $_mirror->getConstructor() ? $_mirror->newInstanceArgs($this->_getCacheTypeArguments($type)) : $_mirror->newInstance();
if (null !== $namespace) {
$this->_store->setNamespace($namespace);
}
$this->_initializeCache($type);
}
示例7: __construct
/**
* Constructor
*
* $injector function () {return Injector::create([new Module])};
* $initialization function ($instance, InjectorInterface $injector) {};
*
* @param callable $injector
* @param callable $initialization
* @param string $cacheNamespace
* @param CacheProvider $cache
* @param ClassLoaderInterface $classLoader
*/
public function __construct(callable $injector, callable $initialization, $cacheNamespace, CacheProvider $cache, ClassLoaderInterface $classLoader = null)
{
$this->injector = $injector;
$this->initialization = $initialization;
$this->cacheNamespace = $cacheNamespace;
$this->cache = $cache;
$cache->setNamespace($cacheNamespace);
$this->cache = $cache;
$this->classLoader = $classLoader ?: new AopClassLoader();
}
示例8: init
/**
* Initialization that sets a base key and the driver based on configuration settings
*
* @param Grav $grav
*
* @return void
*/
public function init(Grav $grav)
{
/** @var Config $config */
$this->config = $grav['config'];
$this->now = time();
$this->cache_dir = $grav['locator']->findResource('cache://doctrine', true, true);
/** @var Uri $uri */
$uri = $grav['uri'];
$prefix = $this->config->get('system.cache.prefix');
$this->enabled = (bool) $this->config->get('system.cache.enabled');
// Cache key allows us to invalidate all cache on configuration changes.
$this->key = ($prefix ? $prefix : 'g') . '-' . substr(md5($uri->rootUrl(true) . $this->config->key() . GRAV_VERSION), 2, 8);
$this->driver_setting = $this->config->get('system.cache.driver');
$this->driver = $this->getCacheDriver();
// Set the cache namespace to our unique key
$this->driver->setNamespace($this->key);
// Dump Cache state
$grav['debugger']->addMessage('Cache: [' . ($this->enabled ? 'true' : 'false') . '] Setting: [' . $this->driver_setting . '] Driver: [' . $this->driver_name . ']');
}
示例9: init
/**
* Initializes the application instance.
*
* This method
* starts the session,
* call Slim constructor,
* set the custom log writer (if is defined in config),
* bootstraps the Doctrine,
* bootstraps the Auth Manager,
* creates the cache and rcache components,
* sets the file storage,
* adds midlewares,
* instantiates the Route Manager and
* includes the theme.php file of the active theme if the file exists.
*
*
* If the application was previously initiated, this method returns the application in the first line.
*
* @return \MapasCulturais\App
*/
public function init($config = [])
{
if ($this->_initiated) {
return $this;
}
$this->_initiated = true;
if ($config['slim.debug']) {
error_reporting(E_ALL ^ E_STRICT);
}
session_start();
if ($config['app.offline']) {
$bypass_callable = $config['app.offlineBypassFunction'];
if (!is_callable($bypass_callable) || !$bypass_callable()) {
http_response_code(307);
header('Location: ' . $config['app.offlineUrl']);
}
}
// =============== CACHE =============== //
if (key_exists('app.cache', $config) && is_object($config['app.cache']) && is_subclass_of($config['app.cache'], '\\Doctrine\\Common\\Cache\\CacheProvider')) {
$this->_cache = $config['app.cache'];
} else {
$this->_cache = new \Doctrine\Common\Cache\ArrayCache();
}
$this->_cache->setNamespace($config['app.cache.namespace']);
spl_autoload_register(function ($class) use($config) {
$cache_id = "AUTOLOAD_CLASS:{$class}";
if ($config['app.useRegisteredAutoloadCache'] && $this->cache->contains($cache_id)) {
$path = $this->cache->fetch($cache_id);
require_once $path;
return true;
}
foreach ($config['namespaces'] as $namespace => $base_dir) {
if (strpos($class, $namespace) === 0) {
$path = str_replace('\\', '/', str_replace($namespace, $base_dir, $class) . '.php');
if (\file_exists($path)) {
require_once $path;
if ($config['app.useRegisteredAutoloadCache']) {
$this->cache->save($cache_id, $path, $config['app.registeredAutoloadCache.lifetime']);
}
return true;
}
}
}
});
$config['app.mode'] = key_exists('app.mode', $config) ? $config['app.mode'] : 'production';
$this->_config = $config;
$this->_config['path.layouts'] = APPLICATION_PATH . 'themes/active/layouts/';
$this->_config['path.templates'] = APPLICATION_PATH . 'themes/active/views/';
$this->_config['path.metadata_inputs'] = APPLICATION_PATH . 'themes/active/metadata-inputs/';
if (!key_exists('app.sanitize_filename_function', $this->_config)) {
$this->_config['app.sanitize_filename_function'] = null;
}
$theme_class = $config['themes.active'] . '\\Theme';
parent::__construct(['log.level' => $config['slim.log.level'], 'log.enabled' => $config['slim.log.enabled'], 'debug' => $config['slim.debug'], 'templates.path' => $this->_config['path.templates'], 'view' => new $theme_class($config['themes.assetManager']), 'mode' => $this->_config['app.mode']]);
$config = $this->_config;
// custom log writer
if (isset($config['slim.log.writer']) && is_object($config['slim.log.writer']) && method_exists($config['slim.log.writer'], 'write')) {
$log = $this->getLog();
$log->setWriter($config['slim.log.writer']);
}
// creates runtime cache component
$this->_rcache = new \Doctrine\Common\Cache\ArrayCache();
// ===================================== //
// ========== BOOTSTRAPING DOCTRINE ========== //
// annotation driver
$doctrine_config = Setup::createConfiguration($config['doctrine.isDev']);
$classLoader = new \Doctrine\Common\ClassLoader('Entities', __DIR__);
$classLoader->register();
$driver = new AnnotationDriver(new AnnotationReader());
$driver->addPaths([__DIR__ . '/Entities/']);
// tells the doctrine to ignore hook annotation.
AnnotationReader::addGlobalIgnoredName('hook');
// driver must be pdo_pgsql
$config['doctrine.database']['driver'] = 'pdo_pgsql';
// registering noop annotation autoloader - allow all annotations by default
AnnotationRegistry::registerLoader('class_exists');
$doctrine_config->setMetadataDriverImpl($driver);
$proxy_dir = APPLICATION_PATH . 'lib/MapasCulturais/DoctrineProxies';
$proxy_namespace = 'MapasCulturais\\DoctrineProxies';
$doctrine_config->setProxyDir($proxy_dir);
//.........这里部分代码省略.........
示例10: __construct
/**
* @param CacheProvider $cache
* @param PermissionGrantingStrategyInterface $permissionGrantingStrategy
* @param string $prefix
*/
public function __construct(CacheProvider $cache, PermissionGrantingStrategyInterface $permissionGrantingStrategy, $prefix = DoctrineAclCache::PREFIX)
{
$this->cache = $cache;
$this->cache->setNamespace($prefix);
parent::__construct($this->cache, $permissionGrantingStrategy, $prefix);
}
示例11: __construct
public function __construct(CacheProvider $provider, $namespace = '', $defaultLifetime = 0)
{
parent::__construct('', $defaultLifetime);
$this->provider = $provider;
$provider->setNamespace($namespace);
}
示例12: setNamespace
/**
* {@inheritdoc}
*/
public function setNamespace($namespace)
{
$this->provider->setNamespace($namespace);
}
示例13: setCache
/**
* @param CacheProvider $cache
* @return Configuration
*/
public function setCache(CacheProvider $cache)
{
// Set namespace for doctrine cache provider to avoid collisions
$namespace = !is_null($this->cacheNamespace) ? $this->cacheNamespace : md5($this->getProxyDir() . \Shopware::REVISION);
$cache->setNamespace("dc2_" . $namespace . "_");
$this->setMetadataCacheImpl($cache);
$this->setQueryCacheImpl($cache);
$this->setResultCacheImpl($cache);
return $this;
}
示例14:
function __construct(CacheProvider $cacheProvider)
{
$this->cacheProvider = $cacheProvider;
$this->cacheProvider->setNamespace('KayueEssenceBundle');
}
示例15: setCache
/**
* @inheritDoc
*
* @param CacheProvider $cache doctrine cache provider
* @param string $cacheNamespace cache namespace
* @param int $cacheLifetime cache lifetime
*
* @return void
*/
public function setCache(CacheProvider $cache, $cacheNamespace, $cacheLifetime)
{
$this->cache = $cache;
$this->cache->setNamespace($cacheNamespace);
$this->cacheLifetime = $cacheLifetime;
}