diff --git a/composer.json b/composer.json index 86a9830751..6b0591dff2 100644 --- a/composer.json +++ b/composer.json @@ -25,6 +25,7 @@ "require": { "php": ">= 7.1", "ext-json": "*", + "nesbot/carbon": "^1.26.0 || ^2.0", "illuminate/contracts": "5.5.* || 5.6.* || 5.7.* || 5.8.* || ^6.0 || ^7.0", "illuminate/http": "5.5.* || 5.6.* || 5.7.* || 5.8.* || ^6.0 || ^7.0", "illuminate/pagination": "5.5.* || 5.6.* || 5.7.* || 5.8.* || ^6.0 || ^7.0", diff --git a/src/Subscriptions/StorageManager.php b/src/Subscriptions/StorageManager.php index fdbf5dd8ba..3397bb01de 100644 --- a/src/Subscriptions/StorageManager.php +++ b/src/Subscriptions/StorageManager.php @@ -2,6 +2,7 @@ namespace Nuwave\Lighthouse\Subscriptions; +use Carbon\Carbon; use Illuminate\Cache\CacheManager; use Illuminate\Support\Arr; use Illuminate\Support\Collection; @@ -78,7 +79,8 @@ public function storeSubscriber(Subscriber $subscriber, string $topic): void if ($this->ttl === null) { $this->cache->forever($channelKey, $subscriber); } else { - $this->cache->put($channelKey, $subscriber, $this->ttl); + // TODO: Change to just pass the ttl directly when support for Laravel <=5.7 is dropped + $this->cache->put($channelKey, $subscriber, Carbon::now()->addSeconds($this->ttl)); } } @@ -103,7 +105,8 @@ protected function storeTopic(string $key, Collection $topic): void if ($this->ttl === null) { $this->cache->forever($key, $topic); } else { - $this->cache->put($key, $topic, $this->ttl); + // TODO: Change to just pass the ttl directly when support for Laravel <=5.7 is dropped + $this->cache->put($key, $topic, Carbon::now()->addSeconds($this->ttl)); } }