1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace PhpWinTools\WmiScripting\Support\Cache; |
4
|
|
|
|
5
|
|
|
use Psr\SimpleCache\CacheInterface; |
6
|
|
|
use PhpWinTools\WmiScripting\Configuration\Config; |
7
|
|
|
|
8
|
|
|
class CacheProvider implements CacheInterface |
9
|
|
|
{ |
10
|
|
|
protected $config; |
11
|
|
|
|
12
|
|
|
/** @var CacheDriver */ |
13
|
|
|
protected $cacheDriver; |
14
|
|
|
|
15
|
|
|
public function __construct(Config $config = null, CacheDriver $cacheDriver = null) |
16
|
|
|
{ |
17
|
|
|
$this->config = $config ?? Config::instance(); |
18
|
|
|
|
19
|
|
|
$this->cacheDriver = $cacheDriver ?? $this->config->getCacheDriver(); |
20
|
|
|
} |
21
|
|
|
|
22
|
|
|
public function get($key, $default = null) |
23
|
|
|
{ |
24
|
|
|
return $this->cacheDriver->get($key, $default); |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
public function set($key, $value, $ttl = null) |
28
|
|
|
{ |
29
|
|
|
return $this->cacheDriver->set($key, $value, $ttl); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
public function delete($key) |
33
|
|
|
{ |
34
|
|
|
return $this->cacheDriver->delete($key); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
public function clear() |
38
|
|
|
{ |
39
|
|
|
return $this->cacheDriver->clear(); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
public function getMultiple($keys, $default = null) |
43
|
|
|
{ |
44
|
|
|
return $this->cacheDriver->getMultiple($keys, $default); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
public function setMultiple($values, $ttl = null) |
48
|
|
|
{ |
49
|
|
|
return $this->cacheDriver->setMultiple($values, $ttl); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
public function deleteMultiple($keys) |
53
|
|
|
{ |
54
|
|
|
return $this->cacheDriver->deleteMultiple($keys); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
public function has($key) |
58
|
|
|
{ |
59
|
|
|
return $this->cacheDriver->has($key); |
60
|
|
|
} |
61
|
|
|
} |
62
|
|
|
|