diff --git a/composer.json b/composer.json index b3ab497e..8640b9b4 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,7 @@ "psr/cache": "^1.0 || ^2.0 || ^3.0", "ray/aop": "^2.10", "ray/di": "^2.13.1", - "ray/psr-cache-module": "^1.3.2", + "ray/psr-cache-module": "^1.3.4", "symfony/cache": "^5.3 || ^6.0", "symfony/cache-contracts": "^2.4 || ^3.0" }, diff --git a/src/StorageMemcachedModule.php b/src/StorageMemcachedModule.php index 29fc01b4..af837325 100644 --- a/src/StorageMemcachedModule.php +++ b/src/StorageMemcachedModule.php @@ -8,8 +8,8 @@ use Psr\Cache\CacheItemPoolInterface; use Ray\Di\AbstractModule; use Ray\PsrCacheModule\Annotation\CacheNamespace; +use Ray\PsrCacheModule\MemcachedAdapter; use Ray\PsrCacheModule\Psr6MemcachedModule; -use Symfony\Component\Cache\Adapter\MemcachedAdapter; final class StorageMemcachedModule extends AbstractModule { diff --git a/src/StorageRedisMemcachedModule.php b/src/StorageRedisMemcachedModule.php index edd8b106..21a285bf 100644 --- a/src/StorageRedisMemcachedModule.php +++ b/src/StorageRedisMemcachedModule.php @@ -10,9 +10,9 @@ use Ray\Di\AbstractModule; use Ray\PsrCacheModule\Annotation\CacheNamespace; use Ray\PsrCacheModule\Annotation\MemcacheConfig; +use Ray\PsrCacheModule\MemcachedAdapter; use Ray\PsrCacheModule\MemcachedProvider; use Ray\PsrCacheModule\Psr6RedisModule; -use Symfony\Component\Cache\Adapter\MemcachedAdapter; use function array_map; use function explode; @@ -44,8 +44,10 @@ protected function configure(): void $this->install(new Psr6RedisModule($this->redisServer)); $this->bind(CacheItemPoolInterface::class)->annotatedWith(EtagPool::class)->toConstructor(MemcachedAdapter::class, [ 'namespace' => CacheNamespace::class, + 'clientProvider' => 'memcached', ]); $this->bind()->annotatedWith(MemcacheConfig::class)->toInstance($this->memcacheServer); + $this->bind(MemcachedProvider::class); $this->bind(Memcached::class)->toProvider(MemcachedProvider::class); } } diff --git a/tests-pecl-ext/StorageMemcachedModuleTest.php b/tests-pecl-ext/StorageMemcachedModuleTest.php index 9724aec2..9d79ab4e 100644 --- a/tests-pecl-ext/StorageMemcachedModuleTest.php +++ b/tests-pecl-ext/StorageMemcachedModuleTest.php @@ -8,11 +8,11 @@ use Psr\Cache\CacheItemPoolInterface; use Ray\Di\Injector; use Ray\PsrCacheModule\Annotation\Shared; -use Symfony\Component\Cache\Adapter\MemcachedAdapter; +use Ray\PsrCacheModule\MemcachedAdapter; class StorageMemcachedModuleTest extends TestCase { - public function testNew() + public function testNew(): void { // @see http://php.net/manual/en/memcached.addservers.php $servers = 'mem1.domain.com:11211:33,mem2.domain.com:11211:67'; diff --git a/tests-pecl-ext/StorageRedisModuleTest.php b/tests-pecl-ext/StorageRedisModuleTest.php index abdea2ee..fded15af 100644 --- a/tests-pecl-ext/StorageRedisModuleTest.php +++ b/tests-pecl-ext/StorageRedisModuleTest.php @@ -9,22 +9,22 @@ use Psr\Cache\CacheItemPoolInterface; use Ray\Di\Injector; use Ray\PsrCacheModule\Annotation\Shared; -use Symfony\Component\Cache\Adapter\MemcachedAdapter; -use Symfony\Component\Cache\Adapter\RedisAdapter; +use Ray\PsrCacheModule\MemcachedAdapter; +use Ray\PsrCacheModule\RedisAdapter; use Symfony\Component\Process\Process; + use function getenv; +use function usleep; class StorageRedisModuleTest extends TestCase { - /** - * @var Process - */ + /** @var Process */ private static $process; /** @var string */ private $server; - public static function setUpBeforeClass() : void + public static function setUpBeforeClass(): void { self::$process = new Process(['redis-server']); self::$process->disableOutput(); @@ -32,24 +32,24 @@ public static function setUpBeforeClass() : void usleep(1000000); //wait for server to get going } - public static function tearDownAfterClass() : void + public static function tearDownAfterClass(): void { self::$process->stop(1); } - protected function setUp() : void + protected function setUp(): void { $this->server = getenv('REDIS_SERVER') ? getenv('REDIS_SERVER') : 'localhost:6379'; } - public function testNew() + public function testNew(): void { // @see http://php.net/manual/en/memcached.addservers.php $cache = (new Injector(new StorageRedisModule($this->server), __DIR__ . '/tmp'))->getInstance(CacheItemPoolInterface::class, Shared::class); $this->assertInstanceOf(RedisAdapter::class, $cache); } - public function testNewRedisMemchache() + public function testNewRedisMemcached(): void { // @see http://php.net/manual/en/memcached.addservers.php $memcacheServers = 'mem1.domain.com:11211:33,mem2.domain.com:11211:67';