Skip to content

Commit 967c4c7

Browse files
committed
fix(cache): handle UnitEnum tags
1 parent 304a635 commit 967c4c7

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

packages/cache/src/CacheInitializer.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace Tempest\Cache;
66

7+
use BackedEnum;
78
use Tempest\Cache\Config\CacheConfig;
89
use Tempest\Container\Container;
910
use Tempest\Container\DynamicInitializer;
@@ -35,14 +36,18 @@ public function initialize(ClassReflector $class, null|string|UnitEnum $tag, Con
3536
);
3637
}
3738

38-
private function shouldCacheBeEnabled(?string $tag): bool
39+
private function shouldCacheBeEnabled(null|string|UnitEnum $tag): bool
3940
{
4041
$globalCacheEnabled = (bool) env('CACHE_ENABLED', default: true);
4142

4243
if (! $tag) {
4344
return $globalCacheEnabled;
4445
}
4546

47+
if ($tag instanceof UnitEnum) {
48+
$tag = $tag->name;
49+
}
50+
4651
$environmentVariableName = str($tag)
4752
->snake()
4853
->upper()

0 commit comments

Comments
 (0)