Skip to content

Commit e57e856

Browse files
authored
Merge pull request #162 from xav-developer/fix/increment-forever
Fix : increment and forever
2 parents 231a23f + a688484 commit e57e856

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ The format is based on [Keep a Changelog][keepachangelog] and this project adher
1818
- Tasks were stuck in case of an error, the "release" method did not return them to the queue.
1919
- The "calculateBackoff" method incorrectly took the index "$job->attempts()"
2020
- The "withHeader" method of the "\Spiral\RoadRunner\Jobs\Task\WritableHeadersInterface" interface expects the type "string|iterable", "int" is passed
21+
- Fixed the `$ttl` in the `increment` method
22+
- The `forever` method passed `$seconds` as 0, `Spiral\RoadRunner\KeyValue` summed `timestamp + 0`, and `forever` was not `forever`
2123

2224
[#147]:https://github.com/roadrunner-php/laravel-bridge/issues/147
2325

src/Cache/RoadRunnerStore.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,12 @@ public function putMany(array $values, $seconds)
6060

6161
public function increment($key, $value = 1)
6262
{
63-
$data = $this->get($this->prefix . $key);
63+
$data = $this->get($key);
6464

6565
return tap(((int) $data) + $value, function ($newValue) use ($key): void {
6666
$ttl = $this->storage->getTtl($this->prefix . $key);
67-
$this->storage->set($key, $newValue, $ttl->diff(new \DateTimeImmutable()));
67+
68+
$this->put($key, $newValue, ($ttl ? $ttl->diff(new \DateTimeImmutable()) : null));
6869
});
6970
}
7071

@@ -75,7 +76,7 @@ public function decrement($key, $value = 1)
7576

7677
public function forever($key, $value)
7778
{
78-
return $this->put($key, $value, 0);
79+
return $this->put($key, $value, null);
7980
}
8081

8182
public function forget($key)

0 commit comments

Comments
 (0)