Skip to content

Commit 64bc69e

Browse files
Merge pull request #6 from AidynMakhataev/dev
fix gc
2 parents 35560af + deb5abc commit 64bc69e

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

src/SessionServiceProvider.php

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

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

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

src/TarantoolSessionHandler.php

Lines changed: 8 additions & 4 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.
@@ -16,6 +15,9 @@ final class TarantoolSessionHandler implements \SessionHandlerInterface
1615
/** @var \Tarantool\Client\Client */
1716
private $client;
1817

18+
/** @var string */
19+
private $spaceName;
20+
1921
/** @var \Tarantool\Client\Schema\Space */
2022
private $space;
2123

@@ -25,11 +27,13 @@ final class TarantoolSessionHandler implements \SessionHandlerInterface
2527
/** @var string */
2628
private $gcFunctionName = 'php_sessions.gc';
2729

28-
public function __construct(Client $client, Space $space)
30+
public function __construct(Client $client, string $spaceName)
2931
{
3032
$this->client = $client;
3133

32-
$this->space = $space;
34+
$this->spaceName = $spaceName;
35+
36+
$this->space = $this->client->getSpace($this->spaceName);
3337

3438
session_set_save_handler($this);
3539
}
@@ -50,7 +54,7 @@ public function destroy($session_id): bool
5054

5155
public function gc($maxlifetime): bool
5256
{
53-
$this->client->call($this->gcFunctionName, $this->space, $maxlifetime);
57+
$this->client->call($this->gcFunctionName, $this->spaceName, $maxlifetime);
5458

5559
return true;
5660
}

0 commit comments

Comments
 (0)