Skip to content

Commit

Permalink
Merge branch '10.0' into 11.0
Browse files Browse the repository at this point in the history
  • Loading branch information
freost committed Jan 16, 2025
2 parents b1d1cc7 + 380e115 commit bfc6aea
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 8 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
### 10.0.12, 11.0.1 <small>(2025-01-16)</small>

#### Compatibility

* Replaced the deprecated SETEX and SETNX redis command calls with SET with the EX and NX options.

--------------------------------------------------------

### 11.0.0 <small>(2025-01-03)</small>

The major version bump is due to upping the required PHP version from `8.1` to `8.4` and a several breaking changes. Most applications built using Mako `10` should run on Mako `11` with just a few simple adjustments.
Expand Down
4 changes: 2 additions & 2 deletions src/mako/cache/stores/Redis.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function put(string $key, mixed $data, int $ttl = 0): bool
return (bool) $this->redis->set($key, $data);
}

return (bool) $this->redis->setex($key, $ttl, $data);
return (bool) $this->redis->set($key, $data, 'EX', $ttl);
}

/**
Expand All @@ -54,7 +54,7 @@ public function putIfNotExists(string $key, mixed $data, int $ttl = 0): bool
$data = is_numeric($data) ? $data : serialize($data);

if ($ttl === 0) {
return (bool) $this->redis->setnx($key, $data);
return (bool) $this->redis->set($key, $data, 'NX');
}

$lua = "return redis.call('exists', KEYS[1]) == 0 and redis.call('setex', KEYS[1], ARGV[1], ARGV[2])";
Expand Down
2 changes: 1 addition & 1 deletion src/mako/session/stores/Redis.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function __construct(
*/
public function write(#[SensitiveParameter] string $sessionId, array $sessionData, int $dataTTL): void
{
$this->redis->setex("{$this->prefix}{$sessionId}", $dataTTL, serialize($sessionData));
$this->redis->set("{$this->prefix}{$sessionId}", serialize($sessionData), 'EX', $dataTTL);
}

/**
Expand Down
8 changes: 4 additions & 4 deletions tests/unit/cache/stores/RedisTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public function testPut(): void

$client = $this->getRedisClient();

$client->shouldReceive('setex')->once()->with('foo', 3600, 123)->andReturn(true);
$client->shouldReceive('set')->once()->with('foo', 123, 'EX', 3600)->andReturn(true);

$redis = new Redis($client);

Expand All @@ -104,7 +104,7 @@ public function testPut(): void

$client = $this->getRedisClient();

$client->shouldReceive('setex')->once()->with('foo', 3600, serialize('foo'))->andReturn(true);
$client->shouldReceive('set')->once()->with('foo', serialize('foo'), 'EX', 3600)->andReturn(true);

$redis = new Redis($client);

Expand All @@ -118,7 +118,7 @@ public function testPutIfNotExists(): void
{
$client = $this->getRedisClient();

$client->shouldReceive('setNx')->once()->with('foo', 123)->andReturn(true);
$client->shouldReceive('set')->once()->with('foo', 123, 'NX')->andReturn(true);

$redis = new Redis($client);

Expand All @@ -128,7 +128,7 @@ public function testPutIfNotExists(): void

$client = $this->getRedisClient();

$client->shouldReceive('setNx')->once()->with('foo', serialize('foo'))->andReturn(true);
$client->shouldReceive('set')->once()->with('foo', serialize('foo'), 'NX')->andReturn(true);

$redis = new Redis($client);

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/session/stores/RedisTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function testWrite(): void
{
$client = $this->getRedisClient();

$client->shouldReceive('setex')->once()->with('sess_123', 123, serialize(['data']));
$client->shouldReceive('set')->once()->with('sess_123', serialize(['data']), 'EX', 123);

$redis = new Redis($client);

Expand Down

0 comments on commit bfc6aea

Please sign in to comment.