Results
11.09.2020
json_field 8.x-1.x-dev ::
tests/src/Kernel/KernelTestBase.php
namespace Drupal\Tests\json_field\Kernel; use Drupal\Component\FileCache\FileCacheFactory; use Drupal\Core\Site\Settings; use Drupal\field\Entity\FieldConfig; use Drupal\field\Entity\FieldStorageConfig; use Drupal\KernelTests\KernelTestBase as DrupalKernelTestBase; /**
*/
protected function setUp(): void {
FileCacheFactory::setPrefix(Settings::getApcuPrefix('file_cache', $this->root));
parent::setUp();
$this->installEntitySchema('user');
$this->installEntitySchema('entity_test');
} 07.04.2020
key_value_field 8.x-1.2 ::
tests/src/Kernel/KernelTestBase.php
namespace Drupal\Tests\key_value_field\Kernel; use Drupal\Component\FileCache\FileCacheFactory; use Drupal\Core\Site\Settings; use Drupal\field\Entity\FieldConfig; use Drupal\field\Entity\FieldStorageConfig; use Drupal\KernelTests\KernelTestBase as DrupalKernelTestBase; /**
*/
protected function setUp(): void {
FileCacheFactory::setPrefix(Settings::getApcuPrefix('file_cache', $this->root));
parent::setUp();
$this->installEntitySchema('user');
$this->installEntitySchema('entity_test');
$this->installConfig(['filter']);
$this->installConfig(['key_value_field']); 01.02.2022
layout_builder_ipe 1.0.x-dev ::
src/Form/LayoutBuilderIpeSettingsForm.php
* The cache factory.
*
* @var \Drupal\Core\Cache\CacheFactoryInterface
*/
protected $cacheFactory;
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
$instance = parent::create($container);
public static function create(ContainerInterface $container) {
$instance = parent::create($container);
$instance->cacheFactory = $container->get('cache_factory');
return $instance;
}
/**
* {@inheritdoc}
*/
if ($original_settings->get('non_concurrent_editing') != $form_state->getValue('non_concurrent_editing')) {
$this->cacheFactory->get('container')->deleteAll();
}
if ($original_settings->get('override_entity_changed_constraint') != $form_state->getValue('override_entity_changed_constraint')) {
$this->cacheFactory->get('discovery')->delete('validation_constraint_plugins');
}
$this->config('layout_builder_ipe.settings')
->set('disable_layout_page', $form_state->getValue('disable_layout_page'))
->set('hide_local_tasks_block', $form_state->getValue('hide_local_tasks_block'))
->set('show_discard_changes_link', $form_state->getValue('show_discard_changes_link'))
->set('enhance_ui', $form_state->getValue('enhance_ui'))
->set('lock_message', $form_state->getValue('lock_message'))
->save();
$this->cacheFactory->get('render')->deleteAll();
Cache::invalidateTags($original_settings->getCacheTags());
parent::submitForm($form, $form_state);
}
} 15.05.2022
media_library_extend_crowdriff 1.x-dev ::
src/Form/CrowdriffConfigForm.php
namespace Drupal\media_library_extend_crowdriff\Form; use Drupal\Core\Cache\CacheFactoryInterface; use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Form\ConfigFormBase; use Drupal\Core\Form\FormStateInterface; use Symfony\Component\DependencyInjection\ContainerInterface; /**
* @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
* The config factory.
* @param \Drupal\Core\Cache\CacheFactoryInterface $cache_factory
* The cache factory.
*/
public function __construct(ConfigFactoryInterface $config_factory, CacheFactoryInterface $cache_factory) {
parent::__construct($config_factory);
$this->cache = $cache_factory->get('media_library_extend_crowdriff');
}
/**
* {@inheritdoc} 25.07.2019
media_mpx 8.x-1.x-dev ::
src/CustomFieldDiscovery.php
use Drupal\Component\Annotation\Doctrine\StaticReflectionParser; use Drupal\Component\Annotation\Reflection\MockFileFinder; use Drupal\Component\FileCache\FileCacheFactory; use Drupal\Component\Utility\Crypt; use Lullabot\Mpx\DataService\Annotation\CustomField; use Lullabot\Mpx\DataService\CustomFieldInterface; use Lullabot\Mpx\DataService\CustomFieldDiscoveryInterface; use Lullabot\Mpx\DataService\DiscoveredCustomField;
$file_cache_suffix = str_replace('\\', '_', $plugin_definition_annotation_name);
$file_cache_suffix .= ':' . Crypt::hashBase64(serialize([]));
$this->fileCache = FileCacheFactory::get('annotation_discovery:' . $file_cache_suffix);
}
/**
* Returns all the Custom Fields.
*
* @return array 25.07.2019
media_mpx 8.x-1.x-dev ::
src/ArrayBackendChainFactory.php
use Drupal\Core\Cache\BackendChain; use Drupal\Core\Cache\CacheFactoryInterface; use Drupal\Core\Site\Settings; use Symfony\Component\DependencyInjection\ContainerAwareTrait; /** * Factory that returns an inconsistent array-backed cache. */
* Factory that returns an inconsistent array-backed cache.
*/
class ArrayBackendChainFactory implements CacheFactoryInterface {
use ContainerAwareTrait;
/**
* The name of the consistent backend cache, typically the database.
* 25.07.2019
media_mpx 8.x-1.x-dev ::
src/ArrayCachePoolFactory.php
use Drupal\Component\Datetime\TimeInterface; use Drupal\Core\Cache\CacheFactoryInterface; use Drupal\Core\Cache\CacheTagsChecksumInterface; use Lullabot\Mpx\Cache\Adapter\PHPArray\ArrayCachePool; /** * Factory that returns an adapted ArrayCachePool. */
* Factory that returns an adapted ArrayCachePool.
*/
class ArrayCachePoolFactory implements CacheFactoryInterface {
/**
* The system time service.
*
* @var \Drupal\Component\Datetime\TimeInterface
*/ 25.09.2020
memcache 8.x-2.2 ::
src/MemcacheBackendFactory.php
namespace Drupal\memcache; use Drupal\Core\Cache\CacheFactoryInterface; use Drupal\Core\Cache\CacheTagsChecksumInterface; use Drupal\memcache\Driver\MemcacheDriverFactory; use Drupal\memcache\Invalidator\TimestampInvalidatorInterface; /** * Defines the memcache backend factory.
* Defines the memcache backend factory.
*/
class MemcacheBackendFactory implements CacheFactoryInterface {
/**
* The memcache factory object.
*
* @var \Drupal\memcache\Driver\MemcacheDriverFactory
*/
* @var \Drupal\memcache\Driver\MemcacheDriverFactory */ protected $memcacheFactory; /** * The cache tags checksum provider. * * @var \Drupal\Core\Cache\CacheTagsChecksumInterface */
*/
public function __construct(MemcacheDriverFactory $memcache_factory, CacheTagsChecksumInterface $checksum_provider, TimestampInvalidatorInterface $timestamp_invalidator) {
$this->memcacheFactory = $memcache_factory;
$this->checksumProvider = $checksum_provider;
$this->timestampInvalidator = $timestamp_invalidator;
}
/**
* Gets MemcacheBackend for the specified cache bin.
return new MemcacheBackend(
$bin,
$this->memcacheFactory->get($bin),
$this->checksumProvider,
$this->timestampInvalidator,
);
}
} 25.09.2020
memcache 8.x-2.2 ::
memcache_admin/src/EventSubscriber/MemcacheAdminSubscriber.php
* @var \Drupal\memcache\Driver\MemcacheDriverFactory */ protected $memcacheFactory; /** * The config factory service. * * @var \Drupal\Core\Config\ConfigFactoryInterface */
*/
public function __construct(MemcacheDriverFactory $memcache_factory, ConfigFactoryInterface $config_factory, AccountInterface $current_user, RendererInterface $renderer) {
$this->memcacheFactory = $memcache_factory;
$this->configFactory = $config_factory;
$this->currentUser = $current_user;
$this->renderer = $renderer;
}
/**
$output = '';
$memcache = $this->memcacheFactory->get(NULL, TRUE);
$memcache_stats = $memcache->requestStats();
if (!empty($memcache_stats['ops'])) {
foreach ($memcache_stats['ops'] as $row => $stats) {
$memcache_stats['ops'][$row][0] = new HtmlEscapedText($stats[0]);
$memcache_stats['ops'][$row][1] = number_format($stats[1], 2);
$hits = number_format($this->statsPercent($stats[2], $stats[3]), 1); 07.06.2021
migrate_scanner 1.0.0-rc1 ::
tests/src/Unit/YamlRecursiveDirectoryDiscoveryTest.php
namespace Drupal\Tests\migrate_scanner\Unit; use Drupal\Component\FileCache\FileCacheFactory; use Drupal\migrate_scanner\Component\Discovery\YamlRecursiveDirectoryDiscovery; use org\bovigo\vfs\vfsStream; use PHPUnit\Framework\TestCase; /** * YamlRecursiveDirectoryDiscovery unit tests.
protected function setUp(): void {
parent::setUp();
// Ensure that FileCacheFactory has a prefix.
FileCacheFactory::setPrefix('prefix');
}
/**
* Tests YAML directory discovery.
*
* @covers ::findAll 04.02.2023
mix 1.1.0-rc1 ::
src/Cache/NullBackendFactory.php
namespace Drupal\mix\Cache;
use Drupal\Core\Cache\CacheFactoryInterface;
use Drupal\Core\Cache\NullBackend;
/**
* Defines the chained fast cache backend factory.
*/
class NullBackendFactory implements CacheFactoryInterface {
/**
* {@inheritdoc}
*/
public function get($bin) {
return new NullBackend($bin); 24.03.2021
o11y 8.x-1.x-dev ::
modules/o11y_metrics/modules/o11y_metrics_cache/src/Cache/CacheFactoryWrapper.php
namespace Drupal\o11y_metrics_cache\Cache; use Drupal\Core\Cache\CacheFactoryInterface; use Symfony\Component\DependencyInjection\ContainerAwareInterface; use Symfony\Component\DependencyInjection\ContainerAwareTrait; /** * Decorates cache_factory. */
* Decorates cache_factory.
*/
class CacheFactoryWrapper implements CacheFactoryInterface, ContainerAwareInterface {
use ContainerAwareTrait;
/**
* The decorated cache factory.
*
* The decorated cache factory. * * @var \Drupal\Core\Cache\CacheFactoryInterface */ protected $cacheFactory; /** * The bins to exclude from our work. * * @var array */
/**
* Creates a new CacheFactoryWrapper instance.
*
* @param \Drupal\Core\Cache\CacheFactoryInterface $cache_factory
* The cache factory.
* @param string[] $binsBlacklist
* A list of cache bins to exclude.
*/
public function __construct(
CacheFactoryInterface $cache_factory,
array $binsBlacklist
) {
$this->cacheFactory = $cache_factory;
$this->binsBlacklist = $binsBlacklist;
$this->cacheBackends = [];
}
/**
* {@inheritdoc}
if (!$this->isEnabled($bin)) {
// If disabled, return an unwrapped backend.
return $this->cacheFactory->get($bin);
}
if (!isset($this->cacheBackends[$bin])) {
$cache_backend = $this->cacheFactory->get($bin);
$this->cacheBackends[$bin] = new CacheBackendWrapper($cache_backend, $bin, $this->container->get('o11y_metrics.prometheus_bridge'));
}
return $this->cacheBackends[$bin];
}
/** 24.03.2021
o11y 8.x-1.x-dev ::
modules/o11y_metrics/modules/o11y_metrics_cache/o11y_metrics_cache.services.yml
services:
o11y_metrics_cache.cache_factory:
class: Drupal\o11y_metrics_cache\Cache\CacheFactoryWrapper
public: false
decorates: cache_factory
arguments:
- '@o11y_metrics_cache.cache_factory.inner'
- '%o11y_metrics_cache.bins.blacklist%'
properties: 02.07.2020
pax 1.0.0-rc1 ::
src/ShardingFileStorage.php
namespace Drupal\pax; use Drupal\Component\FileCache\FileCacheFactory; use Drupal\Component\FileSecurity\FileSecurity; use Drupal\Component\Serialization\Exception\InvalidDataTypeException; use Drupal\Component\Utility\NestedArray; use Drupal\Core\Config\Entity\ConfigEntityType; use Drupal\Core\Config\StorageException; use Drupal\Core\Config\StorageInterface;
// internal static caching of FileCache is used and thus avoids blowing up
// the APCu cache.
$this->fileCache = FileCacheFactory::get('config', ['cache_backend_class' => NULL]);
}
/**
* Returns the path to the configuration file.
*
* @return string 06.05.2020
pcb 8.x-2.2 ::
src/Commands/PcbCommands.php
use Drupal\Core\Cache\Cache; use Drupal\Core\Cache\CacheFactoryInterface; use Drush\Commands\DrushCommands; use Drush\Exceptions\UserAbortException; /** * A Drush commandfile for pcb module. */
* Cache Factory.
*
* @var \Drupal\Core\Cache\CacheFactoryInterface
*/
private $cacheFactory;
/**
* PcbCommands constructor.
*
* @param \Drupal\Core\Cache\CacheFactoryInterface $cache_factory
* Cache Factory.
*/
public function __construct(CacheFactoryInterface $cache_factory) {
$this->cacheFactory = $cache_factory;
}
/**
* Flush permanent cache bin.
*
* @param string $bin
public function flush(string $bin) {
try {
$cache = $this->cacheFactory->get($bin);
if (method_exists($cache, 'deleteAllPermanent')) {
$cache->deleteAllPermanent();
$this->logger()->success(dt('Deleted all cache for @bin.', ['@bin' => $bin]));
}
else {
$this->logger()->error(dt('@bin bin is not using pcb.', ['@bin' => $bin])); 06.05.2020
pcb 8.x-2.2 ::
modules/pcb_memcache/src/Cache/PermanentMemcacheBackendFactory.php
return new PermanentMemcacheBackend(
$bin,
$this->memcacheFactory->get($bin),
$this->checksumProvider,
$this->timestampInvalidator
);
}
} 27.10.2021
phaxio 1.1.0 ::
src/Services/PhaxioBase.php
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Cache\CacheFactoryInterface;
/**
* Service class for Phaxio API commands.
*/
class PhaxioBase {
* The cache factory service. * * @var \Drupal\Core\Cache\CacheFactoryInterface */ protected $cacheFactory; /** * Phaxio client. * * @var \Phaxio */
* Initialize properties.
*/
public function __construct(ConfigFactoryInterface $config_factory, ModuleHandlerInterface $moduleHandler, CacheFactoryInterface $cacheFactory) {
$this->configFactory = $config_factory;
$this->moduleHandler = $moduleHandler;
$this->cacheFactory = $cacheFactory;
$this->key = $this->getKey();
$this->secret = $this->getSecret();
}
/**
* Get the Phaxio client. 27.10.2021
phaxio 1.1.0 ::
src/Services/Numbers.php
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Cache\CacheFactoryInterface;
/**
* Service class for Phaxio phone number handling.
*/
class Numbers extends PhaxioBase {
* Initialize properties.
*/
public function __construct(ConfigFactoryInterface $config_factory, ModuleHandlerInterface $moduleHandler, CacheFactoryInterface $cacheFactory) {
parent::__construct($config_factory, $moduleHandler, $cacheFactory);
$this->bin = $this->cacheFactory->get('phaxio');
}
/**
* Get all purchased numbers.
*/
public function getAllNumbers($country = NULL): Numbers { 21.07.2020
plugin 8.x-2.8 ::
src/PluginType/PluginTypeManager.php
namespace Drupal\plugin\PluginType; use Drupal\Component\FileCache\FileCacheFactory; use Drupal\Component\Serialization\Yaml; use Drupal\Core\Extension\Extension; use Drupal\Core\Extension\ModuleHandlerInterface; use Symfony\Component\DependencyInjection\ContainerInterface; /**
$files = $this->findFiles();
$providers_by_file = array_flip($files);
$file_cache = FileCacheFactory::get('plugin:plugin_type:' . hash('sha256', serialize($providers)));
// Try to load from the file cache first.
foreach ($file_cache->getMultiple($files) as $file => $plugin_types_by_file) {
$this->pluginTypes = array_merge($this->pluginTypes, $plugin_types_by_file);
unset($providers_by_file[$file]);
} 21.07.2020
plugin 8.x-2.8 ::
tests/src/Unit/PluginType/PluginTypeManagerTest.php
namespace Drupal\Tests\plugin\Unit\PluginType; use Drupal\Component\FileCache\FileCacheFactory; use Drupal\Component\Plugin\PluginManagerInterface; use Drupal\Core\Config\TypedConfigManagerInterface; use Drupal\Core\DependencyInjection\ClassResolverInterface; use Drupal\Core\Extension\Extension; use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\plugin\PluginType\PluginTypeInterface;
protected function setUp(): void {
FileCacheFactory::setPrefix($this->randomMachineName());
$plugin_type_id_a = 'foo';
$this->pluginTypeDefinitions[$plugin_type_id_a] = [
'label' => 'Foo',
'description' => 'This is Foo.',
'provider' => 'foo', 