Skip to content

Commit 7fd6744

Browse files
authored
Verify that function does not exists before declaring it. (#215)
1 parent e33b179 commit 7fd6744

1 file changed

Lines changed: 11 additions & 9 deletions

File tree

SimpleCache/util.php

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,17 @@
1313

1414
use Psr\SimpleCache\CacheInterface;
1515

16-
function remember(CacheInterface $cache, $key, $ttl, callable $createResult)
17-
{
18-
$res = $cache->get($key);
19-
if ($res) {
20-
return $res;
21-
}
16+
if (!function_exists('\Cache\Util\SimpleCache\remember')) {
17+
function remember(CacheInterface $cache, $key, $ttl, callable $createResult)
18+
{
19+
$res = $cache->get($key);
20+
if ($res) {
21+
return $res;
22+
}
2223

23-
$res = $createResult();
24-
$cache->set($key, $res, $ttl);
24+
$res = $createResult();
25+
$cache->set($key, $res, $ttl);
2526

26-
return $res;
27+
return $res;
28+
}
2729
}

0 commit comments

Comments
 (0)