Skip to content

Commit 6fe6df1

Browse files
authored
Merge pull request #29 from chrisryan/master
Add expire TTL to secondary runtime key.
2 parents dc33981 + 2a81bab commit 6fe6df1

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

.github/workflows/php.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ on:
88

99
jobs:
1010
build:
11-
runs-on: ubuntu-18.04
11+
runs-on: ubuntu-latest
1212
strategy:
1313
matrix:
14-
php-versions: ['7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1']
14+
php-versions: ['7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2']
1515
steps:
1616
- name: Checkout
1717
uses: actions/checkout@v2

src/Predis.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ private function cache(string $key, string $value, int $cacheTime = null, float
124124

125125
if ($cacheTime !== null) {
126126
$this->client->expire($key, $cacheTime);
127+
$this->client->expire("{$key}.runtime", $cacheTime);
127128
}
128129
} catch (\Exception $e) {
129130
// We don't want exceptions in accessing the cache to break functionality.

tests/PredisTest.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,10 @@ public function memoizeCallableRefreshRequest()
9696
[$this->equalTo($key), $this->equalTo($cachedValue)],
9797
[$this->equalTo("{$key}.runtime"), $this->lessThan(1)]
9898
);
99-
$client->expects($this->once())->method('expire')->with($this->equalTo($key), $this->equalTo($cacheTime));
99+
$client->expects($this->exactly(2))->method('expire')->withConsecutive(
100+
[$this->equalTo($key), $this->equalTo($cacheTime)],
101+
[$this->equalTo("{$key}.runtime"), $this->equalTo($cacheTime)]
102+
);
100103

101104
$memoizer = new Predis($client, false, 100);
102105

@@ -128,7 +131,10 @@ public function memoizeCallableWithUncachedKey()
128131
[$this->equalTo($key), $this->equalTo($cachedValue)],
129132
[$this->equalTo("{$key}.runtime"), $this->lessThan(1)]
130133
);
131-
$client->expects($this->once())->method('expire')->with($this->equalTo($key), $this->equalTo($cacheTime));
134+
$client->expects($this->exactly(2))->method('expire')->withConsecutive(
135+
[$this->equalTo($key), $this->equalTo($cacheTime)],
136+
[$this->equalTo("{$key}.runtime"), $this->equalTo($cacheTime)]
137+
);
132138

133139
$memoizer = new Predis($client);
134140

0 commit comments

Comments
 (0)