Results

22.07.2020
supercache 2.0.x-dev :: src/KeyValueStore/ChainedStorageExpirable.php
use Drupal\Core\Cache\CacheBackendInterface;
use Drupal\Core\Cache\CacheFactoryInterface;
use Drupal\supercache\Cache\DummyTagChecksum;

/**
 * Defines a default key/value store implementation for expiring items.
 *
 * This key/value store implementation uses the database to store key/value
   * Overrides Drupal\Core\KeyValueStore\StorageBase::__construct().
   *
   * @param CacheFactoryInterface $factory
   *   The cache backend factory.
   * @param string $collection
   *   The name of the collection holding key and value pairs.
   * @param \Drupal\Component\Serialization\SerializationInterface $serializer
   *   The serialization class to use.
   * @param \Drupal\Core\Database\Connection $connection
   *   The name of the SQL table to use, defaults to key_value.
   */
  public function __construct(CacheFactoryInterface $factory, $collection, SerializationInterface $serializer, Connection $connection, $table = 'key_value_expire') {
    parent::__construct($collection, $serializer, $connection, $table);
    // Make sure the collection name passed to the cache factory
    // does not have any dots, or else if using database storage it will
    // crash.
    $sanitized_collection = preg_replace('/[^A-Za-z0-9_]+/', '_', $collection);
    $this->cache = $factory->get($table . '_' . $sanitized_collection);
22.07.2020
supercache 2.0.x-dev :: src/KeyValueStore/KeyValueChainedExpirableFactory.php
use Drupal\Core\Cache\CacheBackendInterface;
use Drupal\Core\Cache\CacheFactoryInterface;
use Drupal\Core\Database\Connection;
use Drupal\Core\Database\Database;

use Drupal\Core\KeyValueStore\KeyValueExpirableFactoryInterface;

/**
   * The cache factory.
   * 
   * @var CacheFactoryInterface
   */
  protected $factory;

  /**
   * Constructs this factory object.
   *
   *   The Connection object containing the key-value tables.
   */
  function __construct(CacheFactoryInterface $factory, SerializationInterface $serializer, Connection $connection) {
    $this->serializer = $serializer;
    $this->connection = $connection;
    $this->factory = $factory;
  }

  protected $backed_by_database;
22.07.2020
supercache 2.0.x-dev :: src/KeyValueStore/ChainedStorageTrait.php
use Drupal\Core\Cache\CacheBackendInterface;
use Drupal\Core\Cache\CacheFactoryInterface;
use Drupal\supercache\Cache\DummyTagChecksum;

trait ChainedStorageTrait {

  /**
   * The cache backend.
22.07.2020
supercache 2.0.x-dev :: src/Tests/Generic/Cache/CacheTagsChecksumTests.php
   * The cache factory.
   *
   * @var \Drupal\Core\Cache\CacheFactoryInterface
   */
  protected $backendFactory;

  /**
   * Tag invalidator.
   *
22.07.2020
supercache 2.0.x-dev :: src/Tests/Generic/Cache/CacheServicesTrait.php
   * depend on caches.
   *
   * \Drupal\Core\Cache\CacheFactoryInterface
   *
   * @return string[]
   *   The name of the populated services.
   */
  protected function populateCacheServices() {
22.07.2020
supercache 2.0.x-dev :: src/Cache/CacheCacheTagsChecksum.php
use Drupal\Core\Cache\CacheTagsChecksumInterface;
use Drupal\Core\Cache\CacheBackendInterface;
use Drupal\Core\Cache\CacheFactoryInterface;

/**
 * Cache tags invalidations checksum implementation that uses
 * a CacheRawBackendInterface as the storage.
 */
class CacheCacheTagsChecksum implements CacheTagsChecksumInterface, CacheTagsInvalidatorInterface {
22.07.2020
supercache 2.0.x-dev :: src/Cache/ChainedFastRawBackendFactory.php
use Drupal\Core\Site\Settings;
use Drupal\Core\Cache\CacheFactoryInterface;
use Drupal\Core\Cache\CacheBackendInterface;

use Symfony\Component\HttpKernel\Event\PostResponseEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpKernel\KernelEvents;
22.07.2020
supercache 2.0.x-dev :: src/Cache/ChainedFastBackendFactory.php
use Drupal\Core\Site\Settings;
use Drupal\Core\Cache\CacheFactoryInterface;

use Symfony\Component\HttpKernel\Event\PostResponseEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpKernel\KernelEvents;

use Symfony\Component\DependencyInjection\ContainerAwareTrait;
 * Defines the chained fast cache backend factory.
 */
class ChainedFastBackendFactory implements CacheFactoryInterface, EventSubscriberInterface {

  use ContainerAwareTrait;

  /**
   * The service name of the consistent backend factory.
   *
22.07.2020
supercache 2.0.x-dev :: src/Cache/ApcuRawBackendFactory.php
use Drupal\Core\Site\Settings;
use Drupal\Core\Cache\CacheFactoryInterface;

class ApcuRawBackendFactory implements CacheRawFactoryInterface {

  /**
   * The cache tags checksum provider.
   *
17.08.2018
tmgmt_globaldoc 8.x-1.0 :: src/Plugin/tmgmt/Translator/GlobalDocTranslator.php
namespace Drupal\tmgmt_globaldoc\Plugin\tmgmt\Translator;

use Drupal\Component\FileCache\FileCacheFactory;
use Drupal\Core\File\FileSystemInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\tmgmt\JobInterface;
use Drupal\tmgmt\TMGMTException;
use Drupal\tmgmt\Translator\TranslatableResult;
use Drupal\tmgmt\TranslatorInterface;
    // Use a cache that depends on the file.
    $file_cache = FileCacheFactory::get('tmgmt_globaldoc_language_list');
    if ($remote_languages = $file_cache->get($filepath)) {
      return $remote_languages;
    }

    $remote_languages = [];
    $handle = fopen($filepath, 'r');
26.07.2020
wincachedrupal 8.0.2 :: src/Cache/WincacheBackendFactory.php
use Drupal\Core\Site\Settings;

use Drupal\Core\Cache\CacheFactoryInterface;
use Drupal\Core\Cache\CacheTagsChecksumInterface;

/**
 * Implements the WinCacheBackend cache factory classes.
 */
class WincacheBackendFactory implements CacheFactoryInterface {

  /**
   * The site prefix string.
   *
   * @var string
   */
26.07.2020
wincachedrupal 8.0.2 :: wincachedrupal.services.yml
    arguments: ['@app.root', '@site.path']
  keyvalue.wincache:
    class: Drupal\wincachedrupal\KeyValueStorage\KeyValueWincacheFactory
    arguments: ['@serialization.phpserialize', '@database']
  keyvalue.expirable.wincache:
    class: Drupal\wincachedrupal\wincachedrupal\KeyValueWincacheExpirableFactory
    arguments: ['@serialization.phpserialize', '@database']
  wincachedrupal.eventsubscriber:
    class: Drupal\wincachedrupal\EventSubscriber
14.01.2020
workspaces_route_lock 8.x-1.0-alpha5 :: src/RouteLockedWorkspacesManager.php
use Drupal\Core\Cache\Cache;
use Drupal\Core\Cache\CacheFactoryInterface;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Messenger\MessengerInterface;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\workspaces\Entity\Workspace;
use Drupal\workspaces\WorkspaceInterface;
use Drupal\workspaces\WorkspaceManagerInterface;
   * @param \Drupal\Core\Routing\RouteMatchInterface $currentRouteMatch
   *   The current route match.
   * @param \Drupal\Core\Cache\CacheFactoryInterface $cache
   *   The cache factory.
   */
  public function __construct(WorkspaceManagerInterface $workspaceManager, RouteMatchInterface $currentRouteMatch, CacheFactoryInterface $cache, MessengerInterface $messenger) {
    $this->workspacesManager = $workspaceManager;
    $this->currentRouteMatch = $currentRouteMatch;
    $this->cache = $cache->get('default');
    $this->messanger = $messenger;
  }
04.06.2021
drupal_static_autoloader 01.0 :: src/Drupal/ExtensionDiscovery.php
namespace mglaman\DrupalStaticAutoloader\Drupal;

use Drupal\Component\FileCache\FileCacheFactory;
use Drupal\Core\DrupalKernel;
use Drupal\Core\Extension\Discovery\RecursiveExtensionFilterIterator;
use Drupal\Core\Site\Settings;
use Symfony\Component\HttpFoundation\Request;

/**
25.09.2021
heisencache 8.x-1.x-dev :: src/CacheFactory.php
namespace Drupal\heisencache;

use Drupal\Core\Cache\CacheFactoryInterface;
use Drupal\heisencache\Event\EventDispatcherTrait;
use Drupal\heisencache\Event\FactoryGetEvent;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;

/**
 * Class CacheFactory is a decorator for the core CacheFactory.
 *
 * It adds event generation around the core methods, and builds decorated
 * CacheBacking instances.
 *
 * @package Drupal\heisencache
 *
 * @license General Public License version 2 or later
 */
class CacheFactory implements CacheFactoryInterface {

  use EventDispatcherTrait;

  const FACTORY_GET = 'factory get';

  /**
   * The core cache service.
   *
   * @var \Drupal\Core\Cache\CacheFactoryInterface
   */
  protected CacheFactoryInterface $coreFactory;

  /**
   * The constructor.
   *
   * @param \Symfony\Component\EventDispatcher\EventDispatcherInterface $dispatcher
   *   The event_dispatcher service.
   * @param \Symfony\Component\EventDispatcher\EventDispatcherInterface $dispatcher
   *   The event_dispatcher service.
   * @param \Drupal\Core\Cache\CacheFactoryInterface $core_factory
   *   The core cache service.
   */
  public function __construct(EventDispatcherInterface $dispatcher, CacheFactoryInterface $core_factory) {
    $this->coreFactory = $core_factory;
    $this->dispatcher = $dispatcher;
  }

  /**
   * {@inheritdoc}
08.07.2023
cache_ui 1.0.0 :: src/Controller/CacheUiController.php
namespace Drupal\cache_ui\Controller;

use Drupal\Core\Cache\CacheFactory;
use Drupal\Core\Cache\DatabaseBackend;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\Datetime\DateFormatterInterface;
use Drupal\Core\Link;
use Drupal\Core\Url;
   * Cache factory instance.
   *
   * @var \Drupal\Core\Cache\CacheFactory
   */
  protected $cacheFactory;

  /**
   * Config factory instance.
   *
   * @var \Drupal\Core\Cache\CacheFactory
   */
  protected $configFactory;

  /**
   * Date formatter instance.
   *
   * Constructs the CacheUiController object.
   *
   * @param \Drupal\Core\Cache\CacheFactory $cache_factory
   * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
   * @param \Drupal\Core\Datetime\DateFormatterInterface $date_formatter
   * @param \Symfony\Component\HttpFoundation\Request $request
   */
  public function __construct(CacheFactory $cache_factory, ConfigFactoryInterface $config_factory, DateFormatterInterface $date_formatter, Request $request) {
    $this->cacheFactory = $cache_factory;
    $this->configFactory = $config_factory;
    $this->dateFormatter = $date_formatter;
    $this->request = $request;
  }

  /**
   */
  public function clearBin($bin) {
    $cache_bin = $this->cacheFactory->get($bin);
    $cache_bin->deleteAll();

    $this->messenger()->addStatus($this->t('Cache bin @bin cleared.', ['@bin' => $bin]));

    return new RedirectResponse(Url::fromRoute('cache_ui.admin')->toString());
  }
17.04.2024
momento 1.0.0 :: src/MomentoCacheBackendFactory.php
namespace Drupal\momento_cache;

use Drupal\Core\Cache\CacheFactoryInterface;
use Drupal\Core\Cache\CacheTagsChecksumInterface;
use Drupal\Core\Site\Settings;
use Drupal\momento_cache\Client\MomentoClientFactory;

class MomentoCacheBackendFactory implements CacheFactoryInterface {

    private $momentoFactory;
    private $checksumProvider;

    private static $cacheName;
    private $client;
13.02.2024
packthub_ebook_integration 1.0.0 :: src/Plugin/EbookDefinition.php
  public function packthubFields():array {

    $cacheFactory = \Drupal::cache();
    $cacheId = 'packt_first_product';

    $dd = $cacheFactory->get($cacheId)->data ?? NULL;

    if(empty($dd)) {
      $pro = new Products();
      $pro->setLimit(1);
      $pro->setFilter('product_type','=', 'book');
      $prod = $pro->getProducts(all: FALSE);
      $dd = $pro->getProducts();
      // Store the array in the cache
      $cacheFactory->set($cacheId, $dd, CacheBackendInterface::CACHE_PERMANENT);

    }
    if(!empty($dd)) {
      $fields = [
        'product_id' => 'Product ID',
        'product_type' => 'Product Type',
13.02.2024
packthub_ebook_integration 1.0.0 :: src/Controller/ProductsDashboard.php
    // Let's check in the cache for this page
    $cacheFactory = \Drupal::cache();
    $cacheId = 'packt_page_products_'.$page;

    // To retrieve the cached array:
    $products = $cacheFactory->get($cacheId)->data ?? NULL;

    if(empty($products)) {

      // Lets get products
      $prod = new Products();
      $prod->setLimit(21);
    // Get the cache factory from the container
    $cacheFactory = \Drupal::cache();

    $cacheId = 'packt_page_products_'.$page;

    // Store the array in the cache
    $cacheFactory->set($cacheId, $details, CacheBackendInterface::CACHE_PERMANENT);

    return $details;
  }

  public function productsSearch(Request $request): JsonResponse {
        $message = $ebooks->getMessages();
        $cacheId = random_int(100, 1000);
        $cacheFactory = \Drupal::cache();
        $cacheFactory->set($cacheId, $data, CacheBackendInterface::CACHE_PERMANENT);
        $save = Url::fromRoute('packt.ebook_action',['action'=>'save','id'=>$cacheId])->toString();
        $delete = Url::fromRoute('packt.ebook_action',['action'=>'delete','id'=>$cacheId])->toString();
        return (new JsonResponse(['results'=> $message, 'save' => $save, 'delete'=>$delete], 200));
      }
      else {
        $url = Url::fromRoute('packt.ebook_configure')->toString();
    $action = $request->get('action');

    $cacheFactory = \Drupal::cache();
    $nodes = $cacheFactory->get($cacheId)->data ?? NULL;

    if($action === 'save') {
      if(!empty($nodes)) {
        foreach ($nodes as $node) {
          if($node instanceof Node) {
            $node->save();
        $url = Url::fromRoute('packt.products')->toString();
        $cacheFactory->delete($cacheId);
        (new RedirectResponse($url))->send();
      }
    }

    if($action === 'delete') {
      $configuration = packt_ebook_maps();
        $cacheFactory->delete($cacheId);

        \Drupal::messenger()->addMessage("Ebook creation cancelled successfully");
        $url = Url::fromRoute('packt.products')->toString();
        $cacheFactory->delete($cacheId);
        (new RedirectResponse($url))->send();
      }
    }
    return ['#markup' => 'Something went wrong'];
  }
  public function totalPages(): int {
    $cacheFactory = \Drupal::cache();
    $cacheId = 'packt_page_products_meta';

    // To retrieve the cached array:
    $meta = $cacheFactory->get($cacheId)->data ?? NULL;
    if(!empty($meta)) {
      return $meta;
    }
    $pr = new Products();
    $pr->setLimit(1);
    $pr->setFilter('product_type', '=', 'book');
      // Store the array in the cache
      $cacheFactory->set($cacheId, $product['last_page'], CacheBackendInterface::CACHE_PERMANENT);
      return $product['last_page'];
    }
    return  100;
  }
}
06.12.2024
skinr 8.x-2.0-alpha2 :: src/Component/Discovery/SkinYamlDirectoryDiscovery.php
use Drupal\Component\Discovery\DiscoverableInterface;
use Drupal\Component\FileCache\FileCacheFactory;
use Drupal\Component\Serialization\Exception\InvalidDataTypeException;
use Drupal\Component\Serialization\Yaml;

/**
 * Discovers multiple YAML files in a set of directories.
 *
    $files = $this->findFiles();

    $file_cache = FileCacheFactory::get('yaml_discovery:' . $this->fileCacheKeySuffix);

    // Try to load from the file cache first.
    foreach ($file_cache->getMultiple(array_keys($files)) as $file => $data) {
      $all[$files[$file]][$this->getIdentifier($file, $data)] = $data + ['path' => $file];
      unset($files[$file]);
    }

Pages

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc