Skip to content

Commit 840aa34

Browse files
author
Aidyn Makhataev
committed
Fix tarantool session gc
1 parent c3d697a commit 840aa34

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

src/SessionServiceProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function boot(): void
4444
'password' => $options['password'],
4545
]);
4646

47-
return new TarantoolSessionHandler($client, $client->getSpace($options['space']));
47+
return new TarantoolSessionHandler($client, $options['space']);
4848
});
4949

5050
Session::extend('tarantool', static function (Application $app) {

src/TarantoolSessionHandler.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
use Tarantool\Client\Client;
88
use Tarantool\Client\Schema\Criteria;
9-
use Tarantool\Client\Schema\Space;
109

1110
/**
1211
* Class TarantoolSessionHandler
@@ -17,7 +16,10 @@ final class TarantoolSessionHandler implements \SessionHandlerInterface
1716
/** @var \Tarantool\Client\Client */
1817
private $client;
1918

20-
/** @var \Tarantool\Client\Schema\Space */
19+
/** @var string */
20+
private $spaceName;
21+
22+
/** @var \Tarantool\Client\Schema\Space */
2123
private $space;
2224

2325
/** @var string */
@@ -26,11 +28,13 @@ final class TarantoolSessionHandler implements \SessionHandlerInterface
2628
/** @var string */
2729
private $gcFunctionName = 'php_sessions.gc';
2830

29-
public function __construct(Client $client, Space $space)
31+
public function __construct(Client $client, string $spaceName)
3032
{
3133
$this->client = $client;
3234

33-
$this->space = $space;
35+
$this->spaceName = $spaceName;
36+
37+
$this->space = $this->client->getSpace($this->spaceName);
3438

3539
session_set_save_handler($this);
3640
}
@@ -51,7 +55,7 @@ public function destroy($session_id): bool
5155

5256
public function gc($maxlifetime): bool
5357
{
54-
$this->client->call($this->gcFunctionName, $this->space, $maxlifetime);
58+
$this->client->call($this->gcFunctionName, $this->spaceName, $maxlifetime);
5559

5660
return true;
5761
}

0 commit comments

Comments
 (0)