Skip to content

Commit 5932063

Browse files
danlitmantPl0ch
andauthored
Update SimpleCacheAdapter.php (#60)
When using `SimpleCacheAdapter` with the Laravel Redis cache adapter, the method `getIdWithHash` tries to return the string representation of the value in the store directly. Giving the following exception ```Symfony\Component\Debug\Exception\FatalThrowableError with message 'Return value of FlixTech\SchemaRegistryApi\Registry\Cache\SimpleCacheAdapter::getIdWithHash() must be of the type int or null, string returned'``` Co-authored-by: Thomas Ploch <profiploch@gmail.com>
1 parent 9810ab2 commit 5932063

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/Registry/Cache/SimpleCacheAdapter.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,13 @@ public function getWithId(int $schemaId): ?AvroSchema
7676
*/
7777
public function getIdWithHash(string $hash): ?int
7878
{
79-
80-
return $this->cache->get($hash);
79+
$rawId = $this->cache->get($hash);
80+
81+
if (null === $rawId) {
82+
return null;
83+
}
84+
85+
return (int) $rawId;
8186
}
8287

8388
/**

0 commit comments

Comments
 (0)