Skip to content

Commit dd280ef

Browse files
authored
[6.x] Memoize marketplace cache (#14182)
1 parent 98012be commit dd280ef

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

src/Marketplace/Marketplace.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,14 @@
1111

1212
class Marketplace
1313
{
14+
private static $packagesCache = [];
15+
1416
public function packages(array $packages)
1517
{
1618
$uri = 'packages';
1719
$hash = md5(json_encode($packages));
1820

19-
return Cache::rememberWithExpiration("marketplace-$uri-$hash", function () use ($uri, $packages) {
21+
return static::$packagesCache[$hash] ??= Cache::rememberWithExpiration("marketplace-$uri-$hash", function () use ($uri, $packages) {
2022
try {
2123
$response = Client::post($uri, ['packages' => $packages]);
2224

0 commit comments

Comments
 (0)