1 | <?php |
||
2 | /** |
||
3 | * Class MemcachedDriver |
||
4 | * |
||
5 | * @filesource MemcachedDriver.php |
||
6 | * @created 25.05.2017 |
||
7 | * @package chillerlan\SimpleCache\Drivers |
||
8 | * @author Smiley <[email protected]> |
||
9 | * @copyright 2017 Smiley |
||
10 | * @license MIT |
||
11 | */ |
||
12 | |||
13 | namespace chillerlan\SimpleCache\Drivers; |
||
14 | |||
15 | use chillerlan\SimpleCache\CacheException; |
||
16 | use chillerlan\Traits\ImmutableSettingsInterface; |
||
0 ignored issues
–
show
|
|||
17 | use Memcached; |
||
18 | |||
19 | class MemcachedDriver extends CacheDriverAbstract{ |
||
20 | |||
21 | /** |
||
22 | * @var \Memcached |
||
23 | */ |
||
24 | protected $memcached; |
||
25 | |||
26 | /** |
||
27 | * MemcachedDriver constructor. |
||
28 | * |
||
29 | * @param \Memcached $memcached |
||
30 | * @param \chillerlan\Traits\ImmutableSettingsInterface|null $options |
||
31 | * |
||
32 | * @throws \chillerlan\SimpleCache\CacheException |
||
33 | */ |
||
34 | public function __construct(Memcached $memcached, ImmutableSettingsInterface $options = null){ |
||
35 | parent::__construct($options); |
||
36 | |||
37 | $this->memcached = $memcached; |
||
38 | |||
39 | if(empty($this->memcached->getServerList())){ |
||
40 | $msg = 'no memcache server available'; |
||
41 | |||
42 | $this->logger->error($msg); |
||
43 | throw new CacheException($msg); |
||
44 | } |
||
45 | |||
46 | } |
||
47 | |||
48 | /** @inheritdoc */ |
||
49 | public function get(string $key, $default = null){ |
||
50 | $value = $this->memcached->get($key); |
||
51 | |||
52 | return $value ?: $default; |
||
53 | } |
||
54 | |||
55 | /** @inheritdoc */ |
||
56 | public function set(string $key, $value, int $ttl = null):bool{ |
||
57 | return $this->memcached->set($key, $value, $ttl); |
||
58 | } |
||
59 | |||
60 | /** @inheritdoc */ |
||
61 | public function delete(string $key):bool{ |
||
62 | return $this->memcached->delete($key); |
||
63 | } |
||
64 | |||
65 | /** @inheritdoc */ |
||
66 | public function clear():bool{ |
||
67 | return $this->memcached->flush(); |
||
68 | } |
||
69 | |||
70 | /** @inheritdoc */ |
||
71 | public function getMultiple(array $keys, $default = null):array{ |
||
72 | $values = $this->memcached->getMulti($keys); |
||
73 | $return = []; |
||
74 | |||
75 | foreach($keys as $key){ |
||
76 | $return[$key] = $values[$key] ?? $default; |
||
77 | } |
||
78 | |||
79 | return $return; |
||
80 | } |
||
81 | |||
82 | /** @inheritdoc */ |
||
83 | public function setMultiple(array $values, int $ttl = null):bool{ |
||
84 | return $this->memcached->setMulti($values, $ttl); |
||
85 | } |
||
86 | |||
87 | /** @inheritdoc */ |
||
88 | public function deleteMultiple(array $keys):bool{ |
||
89 | $return = $this->memcached->deleteMulti($keys); |
||
90 | |||
91 | return $this->checkReturn((array)$return); |
||
92 | } |
||
93 | |||
94 | } |
||
95 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths