Skip to content

Commit b1cedc4

Browse files
GinoPanetransistive
authored andcommitted
Fix #158
Use database for cache key so the routing table is built correctly
1 parent f8b683f commit b1cedc4

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/Neo4j/Neo4jConnectionPool.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public function createOrGetPool(UriInterface $uri): ConnectionPool
120120
*/
121121
public function acquire(SessionConfiguration $config): Generator
122122
{
123-
$key = $this->createKey($this->data);
123+
$key = $this->createKey($this->data, $config);
124124

125125
/** @var RoutingTable|null */
126126
$table = $this->cache->get($key, null);
@@ -283,11 +283,14 @@ public function release(ConnectionInterface $connection): void
283283
$this->createOrGetPool($connection->getServerAddress())->release($connection);
284284
}
285285

286-
private function createKey(ConnectionRequestData $data): string
286+
private function createKey(ConnectionRequestData $data, ?SessionConfiguration $config = null): string
287287
{
288288
$uri = $data->getUri();
289289

290-
$key = $data->getUserAgent().':'.$uri->getHost().':'.($uri->getPort() ?? '7687');
290+
$key = implode(
291+
':',
292+
array_filter([$data->getUserAgent(), $uri->getHost(), $config?->getDatabase(), $uri->getPort() ?? '7687'])
293+
);
291294

292295
return str_replace([
293296
'{',

0 commit comments

Comments
 (0)