Skip to content

Commit d76ab34

Browse files
authored
Merge pull request #154 from xav-developer/fix/cache-ttl
Edit the $ttl calculation for the RoadRunnerStore, the time calculation takes place inside the spiral/roadrunner-kv package
2 parents b2ef789 + f364b5f commit d76ab34

File tree

2 files changed

+3
-29
lines changed

2 files changed

+3
-29
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ The format is based on [Keep a Changelog][keepachangelog] and this project adher
66

77
### Fixed
88

9+
- Edit the $ttl calculation for the RoadRunnerStore, the time calculation takes place inside the spiral/roadrunner-kv package
910
- Tasks were stuck in case of an error, the "release" method did not return them to the queue.
1011
- The "calculateBackoff" method incorrectly took the index "$job->attempts()"
1112
- The "withHeader" method of the "\Spiral\RoadRunner\Jobs\Task\WritableHeadersInterface" interface expects the type "string|iterable", "int" is passed

src/Cache/RoadRunnerStore.php

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,10 @@
66

77
use Illuminate\Cache\TaggableStore;
88
use Illuminate\Contracts\Cache\LockProvider;
9-
use Illuminate\Support\InteractsWithTime;
109
use Spiral\RoadRunner\KeyValue\StorageInterface;
1110

1211
final class RoadRunnerStore extends TaggableStore implements LockProvider
1312
{
14-
use InteractsWithTime;
15-
1613
public function __construct(private StorageInterface $storage, private string $prefix = '') {}
1714

1815
public function get($key)
@@ -39,7 +36,7 @@ public function many(array $keys)
3936

4037
public function put($key, $value, $seconds)
4138
{
42-
return $this->storage->set($this->prefix . $key, $value, $this->calculateExpiration($seconds));
39+
return $this->storage->set($this->prefix . $key, $value, $seconds);
4340
}
4441

4542
public function putMany(array $values, $seconds)
@@ -52,7 +49,7 @@ public function putMany(array $values, $seconds)
5249

5350
return $this->storage->setMultiple(
5451
$prefixedValues,
55-
$this->calculateExpiration($seconds),
52+
$seconds,
5653
);
5754
}
5855

@@ -90,28 +87,4 @@ public function getPrefix()
9087
{
9188
return $this->prefix;
9289
}
93-
94-
/**
95-
* Set the cache key prefix.
96-
*/
97-
public function setPrefix(string $prefix): void
98-
{
99-
$this->prefix = !empty($prefix) ? $prefix . ':' : '';
100-
}
101-
102-
/**
103-
* Get the expiration time of the key.
104-
*/
105-
protected function calculateExpiration(int $seconds): int
106-
{
107-
return $this->toTimestamp($seconds);
108-
}
109-
110-
/**
111-
* Get the UNIX timestamp for the given number of seconds.
112-
*/
113-
protected function toTimestamp(int $seconds): int
114-
{
115-
return $seconds > 0 ? $this->availableAt($seconds) : 0;
116-
}
11790
}

0 commit comments

Comments
 (0)