Skip to content

Commit

Permalink
refactor: RedisResourceManager
Browse files Browse the repository at this point in the history
The `RedisResourceManager` is now adapted to work the same way as `RedisClusterResourceManager` while this also removes a bunch of methods which are not meant to be part of the resource manager.

- `Redis` adapter now allows `RedisResourceManagerInterface` to be set via `Redis#setResourceManager`

- `RedisClusterResourceManagerInterface#hasSerializationSupport` now requires both `StorageInterface` and `PluginCapableInterface`
- `RedisCluster#setResourceManager` is not marked as internal anymore

- `RedisClusterResourceManagerInterface#getVersion`
- `RedisClusterResourceManagerInterface#getLibOption`

Signed-off-by: Maximilian Bösing <[email protected]>
  • Loading branch information
boesing committed Jun 21, 2024
1 parent a3492b3 commit 3b61bb6
Show file tree
Hide file tree
Showing 44 changed files with 1,298 additions and 1,816 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@
/test/ export-ignore
/benchmark/ export-ignore
/phpbench.json export-ignore
/psalm export-ignore
19 changes: 9 additions & 10 deletions benchmark/RedisClusterStorageAdapterBench.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,25 @@
namespace LaminasBench\Cache;

use Laminas\Cache\Storage\Adapter\Benchmark\AbstractStorageAdapterBenchmark;
use Laminas\Cache\Storage\Adapter\RedisClusterOptions;
use LaminasTest\Cache\Storage\Adapter\Laminas\RedisClusterStorageCreationTrait;
use PhpBench\Benchmark\Metadata\Annotations\Iterations;
use PhpBench\Benchmark\Metadata\Annotations\Revs;
use PhpBench\Benchmark\Metadata\Annotations\Warmup;
use PhpBench\Attributes\Iterations;
use PhpBench\Attributes\Revs;
use PhpBench\Attributes\Warmup;
use Redis;

/**
* @Revs(100)
* @Iterations(10)
* @Warmup(1)
* @template-extends AbstractStorageAdapterBenchmark<RedisClusterOptions>
*/
#[Revs(100)]
#[Iterations(10)]
#[Warmup(1)]
class RedisClusterStorageAdapterBench extends AbstractStorageAdapterBenchmark
{
use RedisClusterStorageCreationTrait;

public function __construct()
{
parent::__construct($this->createRedisClusterStorage(
Redis::SERIALIZER_NONE,
true
));
parent::__construct($this->createRedisClusterStorage(Redis::SERIALIZER_NONE, true));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,25 @@
namespace LaminasBench\Cache;

use Laminas\Cache\Storage\Adapter\Benchmark\AbstractStorageAdapterBenchmark;
use Laminas\Cache\Storage\Adapter\RedisClusterOptions;
use LaminasTest\Cache\Storage\Adapter\Laminas\RedisClusterStorageCreationTrait;
use PhpBench\Benchmark\Metadata\Annotations\Iterations;
use PhpBench\Benchmark\Metadata\Annotations\Revs;
use PhpBench\Benchmark\Metadata\Annotations\Warmup;
use PhpBench\Attributes\Iterations;
use PhpBench\Attributes\Revs;
use PhpBench\Attributes\Warmup;
use Redis;

/**
* @Revs(100)
* @Iterations(10)
* @Warmup(1)
* @template-extends AbstractStorageAdapterBenchmark<RedisClusterOptions>
*/
#[Revs(100)]
#[Iterations(10)]
#[Warmup(1)]
class RedisClusterWithIgbinarySerializerStorageAdapterBench extends AbstractStorageAdapterBenchmark
{
use RedisClusterStorageCreationTrait;

public function __construct()
{
parent::__construct($this->createRedisClusterStorage(
Redis::SERIALIZER_IGBINARY,
false
));
parent::__construct($this->createRedisClusterStorage(Redis::SERIALIZER_IGBINARY, false));
}
}
19 changes: 9 additions & 10 deletions benchmark/RedisClusterWithPhpSerializerStorageAdapterBench.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,25 @@
namespace LaminasBench\Cache;

use Laminas\Cache\Storage\Adapter\Benchmark\AbstractStorageAdapterBenchmark;
use Laminas\Cache\Storage\Adapter\RedisClusterOptions;
use LaminasTest\Cache\Storage\Adapter\Laminas\RedisClusterStorageCreationTrait;
use PhpBench\Benchmark\Metadata\Annotations\Iterations;
use PhpBench\Benchmark\Metadata\Annotations\Revs;
use PhpBench\Benchmark\Metadata\Annotations\Warmup;
use PhpBench\Attributes\Iterations;
use PhpBench\Attributes\Revs;
use PhpBench\Attributes\Warmup;
use Redis;

/**
* @Revs(100)
* @Iterations(10)
* @Warmup(1)
* @template-extends AbstractStorageAdapterBenchmark<RedisClusterOptions>
*/
#[Revs(100)]
#[Iterations(10)]
#[Warmup(1)]
class RedisClusterWithPhpSerializerStorageAdapterBench extends AbstractStorageAdapterBenchmark
{
use RedisClusterStorageCreationTrait;

public function __construct()
{
parent::__construct($this->createRedisClusterStorage(
Redis::SERIALIZER_PHP,
false
));
parent::__construct($this->createRedisClusterStorage(Redis::SERIALIZER_PHP, false));
}
}
19 changes: 9 additions & 10 deletions benchmark/RedisStorageAdapterBench.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,25 @@
namespace LaminasBench\Cache;

use Laminas\Cache\Storage\Adapter\Benchmark\AbstractStorageAdapterBenchmark;
use Laminas\Cache\Storage\Adapter\RedisOptions;
use LaminasTest\Cache\Storage\Adapter\Laminas\RedisStorageCreationTrait;
use PhpBench\Benchmark\Metadata\Annotations\Iterations;
use PhpBench\Benchmark\Metadata\Annotations\Revs;
use PhpBench\Benchmark\Metadata\Annotations\Warmup;
use PhpBench\Attributes\Iterations;
use PhpBench\Attributes\Revs;
use PhpBench\Attributes\Warmup;
use Redis;

/**
* @Revs(100)
* @Iterations(10)
* @Warmup(1)
* @template-extends AbstractStorageAdapterBenchmark<RedisOptions>
*/
#[Revs(100)]
#[Iterations(10)]
#[Warmup(1)]
class RedisStorageAdapterBench extends AbstractStorageAdapterBenchmark
{
use RedisStorageCreationTrait;

public function __construct()
{
parent::__construct($this->createRedisStorage(
Redis::SERIALIZER_NONE,
true
));
parent::__construct($this->createRedisStorage(Redis::SERIALIZER_NONE, true));
}
}
29 changes: 29 additions & 0 deletions benchmark/RedisWithIgbinarySerializerStorageAdapterBench.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

declare(strict_types=1);

namespace LaminasBench\Cache;

use Laminas\Cache\Storage\Adapter\Benchmark\AbstractStorageAdapterBenchmark;
use Laminas\Cache\Storage\Adapter\RedisOptions;
use LaminasTest\Cache\Storage\Adapter\Laminas\RedisStorageCreationTrait;
use PhpBench\Attributes\Iterations;
use PhpBench\Attributes\Revs;
use PhpBench\Attributes\Warmup;
use Redis;

/**
* @template-extends AbstractStorageAdapterBenchmark<RedisOptions>
*/
#[Revs(100)]
#[Iterations(10)]
#[Warmup(1)]
class RedisWithIgbinarySerializerStorageAdapterBench extends AbstractStorageAdapterBenchmark
{
use RedisStorageCreationTrait;

public function __construct()
{
parent::__construct($this->createRedisStorage(Redis::SERIALIZER_IGBINARY, false));
}
}
29 changes: 29 additions & 0 deletions benchmark/RedisWithPhpSerializerStorageAdapterBench.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

declare(strict_types=1);

namespace LaminasBench\Cache;

use Laminas\Cache\Storage\Adapter\Benchmark\AbstractStorageAdapterBenchmark;
use Laminas\Cache\Storage\Adapter\RedisOptions;
use LaminasTest\Cache\Storage\Adapter\Laminas\RedisStorageCreationTrait;
use PhpBench\Attributes\Iterations;
use PhpBench\Attributes\Revs;
use PhpBench\Attributes\Warmup;
use Redis;

/**
* @template-extends AbstractStorageAdapterBenchmark<RedisOptions>
*/
#[Revs(100)]
#[Iterations(10)]
#[Warmup(1)]
class RedisWithPhpSerializerStorageAdapterBench extends AbstractStorageAdapterBenchmark
{
use RedisStorageCreationTrait;

public function __construct()
{
parent::__construct($this->createRedisStorage(Redis::SERIALIZER_PHP, false));
}
}
5 changes: 2 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@
"laminas/laminas-cache-storage-implementation": "2.0"
},
"require-dev": {
"laminas/laminas-cache": "4.0.x-dev || ^4.0",
"laminas/laminas-cache-storage-adapter-benchmark": "2.0.x-dev || ^2.0",
"laminas/laminas-cache-storage-adapter-test": "3.0.x-dev || ^3.0",
"laminas/laminas-cache-storage-adapter-benchmark": "^2.1",
"laminas/laminas-cache-storage-adapter-test": "^4.0.1",
"laminas/laminas-coding-standard": "~2.5.0",
"laminas/laminas-serializer": "^3.0",
"psalm/plugin-phpunit": "^0.19.0",
Expand Down
Loading

0 comments on commit 3b61bb6

Please sign in to comment.