本文整理汇总了PHP中Doctrine\Common\Cache\Cache::setNamespace方法的典型用法代码示例。如果您正苦于以下问题:PHP Cache::setNamespace方法的具体用法?PHP Cache::setNamespace怎么用?PHP Cache::setNamespace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\Common\Cache\Cache
的用法示例。
在下文中一共展示了Cache::setNamespace方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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'];
/** @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 = substr(md5(($prefix ? $prefix : 'g') . $uri->rootUrl(true) . $this->config->key . GRAV_VERSION), 2, 8);
$this->driver = $this->getCacheDriver();
// Set the cache namespace to our unique key
$this->driver->setNamespace($this->key);
}
示例2: flush
public function flush()
{
foreach ($this->objects as $className => $objects) {
$this->cache->setNamespace($className);
$this->cache->saveMultiple($objects);
}
}
示例3: 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 = $this->getCacheDriver();
// Set the cache namespace to our unique key
$this->driver->setNamespace($this->key);
}
示例4: updateCredentials
/**
* Changes the credentials used to authenticate with QBank.
*
* Changing the credentials will effectively switch the user using QBank and is useful when implementing some tiered
* service.
*
* @param string $user Username of the new user.
* @param string $password Password of the new user.
*
* @return void
*/
public function updateCredentials($user, $password)
{
$oldUser = $this->credentials->getUsername();
$this->credentials = new Credentials($this->credentials->getClientId(), $user, $password);
unset($password);
if ($this->client instanceof Client) {
$this->client->getEmitter()->detach($this->oauth2Subscriber);
$this->oauth2Subscriber = null;
$this->client->getEmitter()->attach($this->getOAuth2Subscriber());
}
if ($this->cache instanceof CacheProvider) {
$this->cache->setNamespace(md5($this->basepath . $this->credentials->getUsername() . $this->credentials->getPassword()));
}
$this->logger->notice('Updated user!', ['old' => $oldUser, 'new' => $user]);
}
示例5: setNamespace
/**
* set namespace to prevent cache naming collision.
*
* @param string $cache_namespace
* @return type
*/
public function setNamespace($cache_namespace)
{
return $this->CacheDriver->setNamespace($cache_namespace);
}
示例6: findOneBy
/**
* @param array $criteria
*
* @return object[]
*/
public function findOneBy(array $criteria)
{
$this->cache->setNamespace($this->className);
$id = $this->getId($criteria);
return $this->cache->fetch($id);
}