Skip to content

Commit

Permalink
Revert "Remove cache"
Browse files Browse the repository at this point in the history
This reverts commit e993f4c.
  • Loading branch information
koriym committed Jul 15, 2021
1 parent e993f4c commit 1a6cd21
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 0 deletions.
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"ext-json": "*",
"bear/resource": "^1.15.4",
"doctrine/annotations": "^1.12",
"doctrine/cache": "^1.10",
"psr/log": "^1.1",
"ray/aop": "^2.10.1",
"ray/di": "^2.11"
Expand Down
18 changes: 18 additions & 0 deletions src/Module/Cache/DoctrineCacheModule.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

declare(strict_types=1);

namespace BEAR\Sunday\Module\Cache;

use Doctrine\Common\Cache\ArrayCache;
use Doctrine\Common\Cache\Cache;
use Ray\Di\AbstractModule;
use Ray\Di\Scope;

class DoctrineCacheModule extends AbstractModule
{
protected function configure(): void
{
$this->bind(Cache::class)->to(ArrayCache::class)->in(Scope::SINGLETON);
}
}
2 changes: 2 additions & 0 deletions src/Module/SundayModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace BEAR\Sunday\Module;

use BEAR\Resource\Module\ResourceModule;
use BEAR\Sunday\Module\Cache\DoctrineCacheModule;
use BEAR\Sunday\Provide\Error\ErrorModule;
use BEAR\Sunday\Provide\Router\RouterModule;
use BEAR\Sunday\Provide\Transfer\HttpCacheModule;
Expand All @@ -16,6 +17,7 @@ class SundayModule extends AbstractModule
protected function configure(): void
{
$this->install(new HttpCacheModule());
$this->install(new DoctrineCacheModule());
$this->install(new ResourceModule());
$this->install(new RouterModule());
$this->install(new HttpResponderModule());
Expand Down
18 changes: 18 additions & 0 deletions tests/Module/Cache/DoctrineCacheModuleTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

declare(strict_types=1);

namespace BEAR\Sunday\Module\Cache;

use Doctrine\Common\Cache\Cache;
use PHPUnit\Framework\TestCase;
use Ray\Di\Injector;

class DoctrineCacheModuleTest extends TestCase
{
public function testGetInstance(): void
{
$cache = (new Injector(new DoctrineCacheModule()))->getInstance(Cache::class);
$this->assertInstanceOf(Cache::class, $cache);
}
}

0 comments on commit 1a6cd21

Please sign in to comment.