Skip to content
Closed
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
13 changes: 11 additions & 2 deletions src/JetStream/KeyValue/Bucket.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,19 @@ public function get(string $key, int $revision = 0): ?Entry
* @param non-empty-string $key
* @return non-negative-int
*/
public function put(string $key, ?string $value = null): int
public function put(string $key, ?string $value = null, ?TimeSpan $ttl = null): int
{
if ($ttl !== null) {
$headers = (new Headers())->with(Header\MsgTtl::Header, $ttl);
} else {
$headers = null;
}

return $this->js
->publish($this->prefixedSubject($key), new Message($value))
->publish($this->prefixedSubject($key), new Message(
payload: $value,
headers: $headers,
))
->seq ?? throw new \LogicException('Sequence expected on kv publish');
}

Expand Down
Loading