本文整理汇总了PHP中Doctrine\Common\Cache\CacheProvider::fetch方法的典型用法代码示例。如果您正苦于以下问题:PHP CacheProvider::fetch方法的具体用法?PHP CacheProvider::fetch怎么用?PHP CacheProvider::fetch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\Common\Cache\CacheProvider
的用法示例。
在下文中一共展示了CacheProvider::fetch方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get
/**
* @param string $key
* @return mixed|null
*/
public function get($key)
{
if (!$this->cache->contains($key)) {
$this->loadSettings();
}
return $this->cache->fetch($key);
}
示例2: getVersion
/**
* @param string $packageName
* @return string
*/
public function getVersion($packageName = OroPlatformBundle::PACKAGE_NAME)
{
// Get package version from local cache if any
if (isset($this->packageVersions[$packageName])) {
return $this->packageVersions[$packageName];
}
// Try to get package version from persistent cache
if ($this->cache && $this->cache->contains($packageName)) {
$version = $this->cache->fetch($packageName);
} else {
// Get package version from composer repository
$packages = $this->factory->getLocalRepository()->findPackages($packageName);
if ($package = current($packages)) {
/** @var PackageInterface $package */
$version = $package->getPrettyVersion();
} else {
$version = self::UNDEFINED_VERSION;
}
//Save package version to persistent cache
if ($this->cache) {
$this->cache->save($packageName, $version);
}
}
// Save package version to local cache
$this->packageVersions[$packageName] = $version;
return $version;
}
示例3: getTimestamp
/**
* Gets the timestamp of the last update of database translations for the given locale
*
* @param string $locale
* @return int|bool timestamp or false if the timestamp is not cached yet
*/
public function getTimestamp($locale)
{
if (!isset($this->localCache[$locale])) {
$this->localCache[$locale] = $this->cacheImpl->fetch($locale);
}
return $this->localCache[$locale];
}
示例4: get
/**
* Build menu.
*
* @param string $alias
* @param array $options
* @return ItemInterface
*/
public function get($alias, array $options = [])
{
$this->assertAlias($alias);
if (!array_key_exists($alias, $this->menus)) {
if ($this->cache && $this->cache->contains($alias)) {
$menuData = $this->cache->fetch($alias);
$this->menus[$alias] = $this->factory->createFromArray($menuData);
} else {
$menu = $this->factory->createItem($alias);
/** @var BuilderInterface $builder */
// try to find builder for the specified menu alias
if (array_key_exists($alias, $this->builders)) {
foreach ($this->builders[$alias] as $builder) {
$builder->build($menu, $options, $alias);
}
}
// In any case we must run common builder
if (array_key_exists(self::COMMON_BUILDER_ALIAS, $this->builders)) {
foreach ($this->builders[self::COMMON_BUILDER_ALIAS] as $builder) {
$builder->build($menu, $options, $alias);
}
}
$this->menus[$alias] = $menu;
$this->eventDispatcher->dispatch(ConfigureMenuEvent::getEventName($alias), new ConfigureMenuEvent($this->factory, $menu));
$this->sort($menu);
if ($this->cache) {
$this->cache->save($alias, $menu->toArray());
}
}
}
return $this->menus[$alias];
}
示例5: get
/**
* @return \Heyday\Redirects\Redirect[]
*/
public function get()
{
$key = $this->dataSource->getKey();
if (!($result = $this->cache->fetch($key))) {
$this->cache->save($key, $result = $this->dataSource->get());
}
return $result;
}
示例6: getCachedAssetVersion
/**
* @param string $packageName
*
* @return int
*/
protected function getCachedAssetVersion($packageName)
{
if (!array_key_exists($packageName, $this->localCache)) {
$version = $this->cache->fetch($packageName);
$this->localCache[$packageName] = false !== $version ? $version : 0;
}
return $this->localCache[$packageName];
}
示例7: build
/**
* (non-PHPdoc)
* @see Generator/Admingenerator\GeneratorBundle\Generator.GeneratorInterface::build()
*/
public function build()
{
if ($this->cacheProvider->fetch($this->getCacheKey())) {
return;
}
$this->doBuild();
$this->cacheProvider->save($this->getCacheKey(), true);
}
示例8: __construct
/**
* @param DocumentFinder $finder For finding documents.
* @param DocumentParser $parser For reading document annotations.
* @param CacheProvider $cache Cache provider to store the meta data for later use.
*/
public function __construct($finder, $parser, $cache = null)
{
$this->finder = $finder;
$this->parser = $parser;
$this->cache = $cache;
if ($this->cache) {
$this->mappings = $this->cache->fetch('ongr.metadata.mappings');
}
}
示例9: getItem
/**
* Get an item.
*
* @param string $cacheId
* @param bool $success
*
* @return mixed Data on success, null on failure
*/
public function getItem($cacheId, &$success = null)
{
if (!$this->hasItem($cacheId)) {
$success = false;
return null;
}
$cacheId = $this->normalizeKey($cacheId);
$success = true;
return unserialize($this->cache->fetch($cacheId));
}
示例10: get
/**
* {@inheritdoc}
*/
public function get(RequesterInterface $requester, ResourceInterface $resource)
{
$cacheId = $this->getCacheId($requester, $resource);
$permission = $this->cacheProvider->fetch($cacheId);
if ($permission instanceof PermissionInterface) {
return $permission;
}
$this->cacheProvider->delete($cacheId);
return;
}
示例11: canReblog
/**
* {@inheritdoc}
*/
public function canReblog($post)
{
$cacheKey = $this->makeCacheKey($post);
$cached = $this->cache->fetch($cacheKey);
if ($cached) {
return false;
}
$this->cache->save($cacheKey, '1', $this->term);
return true;
}
示例12: get
/**
* Returns the data for the given key.
*
* @param string $key The key to search for.
* @param mixed $default Default value to return if there is no data.
*
* @return mixed The cached data, default value or null, if no cache entry exists for the given id.
*/
public function get($key, $default = false)
{
$data = $this->cacheProvider->fetch($key);
if ($data === false && $default !== false) {
return $default;
} elseif ($data === false) {
return null;
}
return $data;
}
示例13: preFind
/**
* @param EventInterface $event
*/
public function preFind(EventInterface $event)
{
if (!preg_match('/\\d$/', $this->cacheId)) {
return;
//The current route is a POST, do not cache new resources with this cache ID
}
if ($this->cache->contains($this->cacheId)) {
$event->stopPropagation(true);
return $this->cache->fetch($this->cacheId);
}
}
示例14: __construct
/**
* @param \Doctrine\Common\Cache\CacheProvider $cacheDriver
*/
public function __construct($cacheDriver = null)
{
if (!is_null($cacheDriver) && class_exists('\\Doctrine\\Common\\Cache\\CacheProvider')) {
if ($cacheDriver instanceof \Doctrine\Common\Cache\CacheProvider) {
$this->cacheDriver = $cacheDriver;
if ($this->cacheDriver->contains($this->cacheKey)) {
$this->data = $this->cacheDriver->fetch($this->cacheKey);
}
}
}
}
示例15: saveCollectInformation
public function saveCollectInformation($id, $information)
{
$this->cache->save($id, $information);
$indexArray = $this->cache->fetch('index');
if (empty($indexArray)) {
$indexArray = [];
}
$indexArray[$id] = array_merge($information['request'], $information['response']);
$this->cache->save('index', $indexArray);
return $id;
}