highwire / drupal-psr-16
将Drupal 8缓存对象转换为PSR-16兼容的缓存对象
2.0.0
2024-09-23 06:15 UTC
Requires
- psr/simple-cache: ^1.0
Requires (Dev)
- drupal/core: ^10.3
- phpunit/phpunit: ^11.3.0
This package is not auto-updated.
Last update: 2024-09-23 06:19:23 UTC
README
将Drupal 8缓存对象转换为PSR-16兼容的缓存对象
安装
composer require highwire\drupal-psr-16
使用PHP
<?php $drupalcache = \Drupal::cache('mybin'); $psr16cache = new \HighWire\DrupalPSR16\Cache($drupalcache); // Now do something with the PSR-16 compliant cache
使用Drupal服务
services: cache.mybin: # Custom cache bin called 'mybin' class: Drupal\Core\Cache\CacheBackendInterface tags: - { name: cache.bin } factory: cache_factory:get arguments: [mybin] psr16.mybin: # PSR 16 service that returns a bin as a PSR-16 compliant object class: HighWire\DrupalPSR16\Cache arguments: ['@cache.mybin'] psr16.default: # PSR 16 service that returns the default bin as a PSR-16 compliant object class: HighWire\DrupalPSR16\Cache arguments: ['@cache.default'] 3rdparty.library: # 3rd Party Library that takes a PSR-16 compliant cache controller class: Some\Third\Party\Library arguments: ['@some.other.service'] calls: - [setCache, ['@psr16.mybin']]