FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Bump utopia-php/pools for pool exhaustion resilience fix by claudear · Pull Request #63 · utopia-php/cache · GitHub

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .json  (1) .lock  (1) .php  (1) All 3 file types selected
Only manifest files
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
5 changes: 3 additions & 2 deletions composer.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"type": "library",
"keywords": ["php","framework", "upf", "utopia", "cache"],
"license": "MIT",
"minimum-stability": "stable",
"minimum-stability": "dev",
"prefer-stable": true,
"scripts": {
"check": "./vendor/bin/phpstan analyse --level max src tests",
"lint": "./vendor/bin/pint --test",
Expand All @@ -22,7 +23,7 @@
"ext-redis": "*",
"ext-memcached": "*",
"utopia-php/telemetry": "*",
"utopia-php/pools": "1.*"
"utopia-php/pools": "dev-fix/pool-empty-resilience as 1.1.0"
},
"require-dev": {
"phpunit/phpunit": "^9.3",
Expand Down
105 changes: 57 additions & 48 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

56 changes: 56 additions & 0 deletions tests/Cache/PoolTest.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,60 @@ public function testGetSize(): void
self::$cache->save('test', 'test');
$this->assertEquals(4, self::$cache->getSize());
}

public function testPoolRetriesAfterConnectionCreationFailure(): void
{
$callCount = 0;
$path = __DIR__.'/tests/pool-retry';
if (! file_exists($path)) {
mkdir($path, 0777, true);
}

$pool = new UtopiaPool(new Stack(), 'retry-test', 2, function () use ($path, &$callCount) {
$callCount++;
if ($callCount === 1) {
throw new \Exception('Transient connection failure');
}

return new Filesystem($path);
});

$cache = new Cache(new Pool($pool));

$result = $cache->save('retry-key', 'retry-value');
$this->assertEquals('retry-value', $result);

$loaded = $cache->load('retry-key', 3600);
$this->assertEquals('retry-value', $loaded);
}

public function testPoolEmptyErrorIncludesDiagnostics(): void
{
$path = __DIR__.'/tests/pool-diag';
if (! file_exists($path)) {
mkdir($path, 0777, true);
}

$pool = new UtopiaPool(new Stack(), 'diag-test', 1, function () use ($path) {
return new Filesystem($path);
});
$pool->setRetryAttempts(1);
$pool->setRetrySleep(0);

// Exhaust the pool by popping the only connection
$connection = $pool->pop();

try {
// This should fail because the pool is exhausted
$pool->pop();
$this->fail('Expected exception was not thrown');
} catch (\Exception $e) {
$this->assertStringContainsString('diag-test', $e->getMessage());
$this->assertStringContainsString('active', $e->getMessage());
$this->assertStringContainsString('idle', $e->getMessage());
}

// Return the connection to clean up
$pool->push($connection);
}
}
Loading

Back | FazBrowse Home | New Git URL