Skip to content

Commit c86fd34

Browse files
authored
Merge pull request #379 from koriym/null-cache
Bind a null cache to the query repository
2 parents d8d21e1 + ba1c990 commit c86fd34

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

src/Module/Psr6NullModule.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace BEAR\Package\Module;
6+
7+
use Psr\Cache\CacheItemPoolInterface;
8+
use Ray\Di\AbstractModule;
9+
use Ray\Di\Scope;
10+
use Ray\PsrCacheModule\Annotation\Local;
11+
use Ray\PsrCacheModule\Annotation\Shared;
12+
use Symfony\Component\Cache\Adapter\NullAdapter;
13+
14+
final class Psr6NullModule extends AbstractModule
15+
{
16+
protected function configure(): void
17+
{
18+
$this->bind(CacheItemPoolInterface::class)->annotatedWith(Local::class)->to(NullAdapter::class)->in(Scope::SINGLETON);
19+
$this->bind(CacheItemPoolInterface::class)->annotatedWith(Shared::class)->to(NullAdapter::class)->in(Scope::SINGLETON);
20+
}
21+
}

src/PackageModule.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace BEAR\Package;
66

7+
use BEAR\Package\Module\Psr6NullModule;
78
use BEAR\Package\Provide\Error\VndErrorModule;
89
use BEAR\Package\Provide\Logger\PsrLoggerModule;
910
use BEAR\Package\Provide\Representation\CreatedResourceModule;
@@ -22,6 +23,7 @@ class PackageModule extends AbstractModule
2223
protected function configure(): void
2324
{
2425
$this->install(new QueryRepositoryModule());
26+
$this->override(new Psr6NullModule());
2527
$this->install(new WebRouterModule());
2628
$this->install(new VndErrorModule());
2729
$this->install(new PsrLoggerModule());

0 commit comments

Comments
 (0)