本文整理匯總了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);
}