-
Notifications
You must be signed in to change notification settings - Fork 0
/
WPObjectCacheDriver.php
47 lines (37 loc) · 1.21 KB
/
WPObjectCacheDriver.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
declare(strict_types=1);
namespace Snicco\Bridge\SessionWP;
use Snicco\Bridge\SessionPsr16\Psr16SessionDriver;
use Snicco\Component\BetterWPCache\CacheFactory;
use Snicco\Component\Session\Driver\SessionDriver;
use Snicco\Component\Session\ValueObject\SerializedSession;
final class WPObjectCacheDriver implements SessionDriver
{
private Psr16SessionDriver $driver;
/**
* @param non-empty-string $cache_group
*/
public function __construct(string $cache_group, int $idle_timeout_in_seconds)
{
$this->driver = new Psr16SessionDriver(CacheFactory::psr16($cache_group), $idle_timeout_in_seconds);
}
public function read(string $selector): SerializedSession
{
return $this->driver->read($selector);
}
public function write(string $selector, SerializedSession $session): void
{
$this->driver->write($selector, $session);
}
public function destroy(string $selector): void
{
$this->driver->destroy($selector);
}
public function gc(int $seconds_without_activity): void
{
}
public function touch(string $selector, int $current_timestamp): void
{
$this->driver->touch($selector, $current_timestamp);
}
}