Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix subscriptions storage manager TTL #1307

Merged
merged 3 commits into from
Apr 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
7 changes: 5 additions & 2 deletions src/Subscriptions/StorageManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Nuwave\Lighthouse\Subscriptions;

use Carbon\Carbon;
use Illuminate\Cache\CacheManager;
use Illuminate\Support\Arr;
use Illuminate\Support\Collection;
Expand Down Expand Up @@ -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));
}
}

Expand All @@ -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));
}
}

Expand Down