Sitelet https://github.com/phpredis/phpredis/commit/b83981aaeb6614754664353d8b4db22f5a631543
Skip to content

Commit b83981a

Browse files
Rework HEXPIRE test inclusion + bump Valkey (#2684)
* Rework `HEXPIRE` test inclusion + bump Valkey * Add a little `haveCommand` helper which uses `COMMAND INFO` to check if a given server has a specific command. This way when we bump valkey to an official release that supports the commands we will start testing. * Bump Valkey from 7.2.5 to 8.1.3 which is much newer. * Rework `haveCommand` to explicitly check for the command name COMMAND INFO will return the command name as one of the first bits of data so we can check for it that way. * Fix incorrect logic
1 parent 6e5faf4 commit b83981a

2 files changed

Lines changed: 12 additions & 5 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ jobs:
121121
- name: Install ValKey
122122
if: matrix.server == 'valkey'
123123
run: |
124-
git clone --depth 1 --branch 7.2.5 https://github.com/valkey-io/valkey.git
124+
git clone --depth 1 --branch 8.1.3 https://github.com/valkey-io/valkey.git
125125
cd valkey && BUILD_TLS=yes sudo make install
126126
127127
- name: Build phpredis

‎tests/RedisTest.php‎

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,13 @@ public function setUp() {
7979
$this->is_valkey = $this->detectValKey($info);
8080
}
8181

82+
protected function haveCommand(string $cmd): bool {
83+
$info = $this->redis->command('info', $cmd);
84+
$name = $info[0][0] ?? null;
85+
86+
return $name && strcasecmp($cmd, $name) === 0;
87+
}
88+
8289
protected function minVersionCheck($version) {
8390
return version_compare($this->version, $version) >= 0;
8491
}
@@ -6298,13 +6305,13 @@ public function testBackoffOptions() {
62986305
}
62996306

63006307
public function testHashExpiration() {
6301-
if ( ! $this->minVersionCheck('7.4.0'))
6308+
if ( ! $this->haveCommand('HEXPIRE'))
63026309
$this->markTestSkipped();
63036310

63046311
$hexpire_cmds = [
6305-
'hexpire' => 10,
6306-
'hpexpire' => 10000,
6307-
'hexpireat' => time() + 10,
6312+
'hexpire' => 10,
6313+
'hpexpire' => 10000,
6314+
'hexpireat' => time() + 10,
63086315
'hpexpireat' => time() * 1000 + 10000,
63096316
];
63106317

0 commit comments

Comments
 (0)