-
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathFactory.php
More file actions
80 lines (69 loc) · 2.39 KB
/
Factory.php
File metadata and controls
80 lines (69 loc) · 2.39 KB
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<?php
namespace ByJG\Cache;
use ByJG\Cache\Psr16\ArrayCacheEngine;
use ByJG\Cache\Psr16\FileSystemCacheEngine;
use ByJG\Cache\Psr16\MemcachedEngine;
use ByJG\Cache\Psr16\TmpfsCacheEngine;
use ByJG\Cache\Psr16\NoCacheEngine;
use ByJG\Cache\Psr16\RedisCacheEngine;
use ByJG\Cache\Psr16\SessionCacheEngine;
use ByJG\Cache\Psr16\ShmopCacheEngine;
use ByJG\Cache\Psr6\CachePool;
use Psr\Log\LoggerInterface;
class Factory
{
public static function createNullPool(): CachePool
{
return new CachePool(
new NoCacheEngine()
);
}
public static function createSessionPool(string $prefix = 'cache', int $bufferSize = 10): CachePool
{
return new CachePool(
new SessionCacheEngine($prefix),
$bufferSize
);
}
public static function createFilePool(string $prefix = 'cache', ?string $path = null, int $bufferSize = 10, ?LoggerInterface $logger = null, bool $createPath = false): CachePool
{
return new CachePool(
new FileSystemCacheEngine($prefix, $path, $logger, $createPath),
$bufferSize
);
}
public static function createShmopPool(array $config = [], int $bufferSize = 10, ?LoggerInterface $logger = null): CachePool
{
return new CachePool(
new ShmopCacheEngine($config, $logger),
$bufferSize
);
}
public static function createArrayPool(int $bufferSize = 10, ?LoggerInterface $logger = null): CachePool
{
return new CachePool(
new ArrayCacheEngine($logger),
$bufferSize
);
}
public static function createMemcachedPool(?array $servers = null, int $bufferSize = 10, ?LoggerInterface $logger = null, ?array $options = null): CachePool
{
return new CachePool(
new MemcachedEngine($servers, $logger, $options),
$bufferSize
);
}
public static function createRedisCacheEngine(?string $servers = null, ?string $password = null, int $bufferSize = 10, ?LoggerInterface $logger = null): CachePool
{
return new CachePool(
new RedisCacheEngine($servers, $password, $logger),
$bufferSize
);
}
public static function createTmpfsCachePool(string $prefix = 'cache', ?LoggerInterface $logger = null): CachePool
{
return new CachePool(
new TmpfsCacheEngine($prefix, $logger)
);
}
}