|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* File containing the ContentHandler implementation. |
|
5
|
|
|
* |
|
6
|
|
|
* @copyright Copyright (C) eZ Systems AS. All rights reserved. |
|
7
|
|
|
* @license For full copyright and license information view LICENSE file distributed with this source code. |
|
8
|
|
|
*/ |
|
9
|
|
|
namespace eZ\Publish\Core\Persistence\Cache; |
|
10
|
|
|
|
|
11
|
|
|
use eZ\Publish\Core\Persistence\Cache\InMemory\MetadataCachePool; |
|
12
|
|
|
use eZ\Publish\SPI\Persistence\Handler as PersistenceHandler; |
|
13
|
|
|
use Symfony\Component\Cache\Adapter\TagAwareAdapterInterface; |
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* Class AbstractHandler. |
|
17
|
|
|
* |
|
18
|
|
|
* Abstract handler for use in other Persistence Cache Handlers. |
|
19
|
|
|
*/ |
|
20
|
|
|
abstract class AbstractInMemoryHandler extends AbstractHandler |
|
21
|
|
|
{ |
|
22
|
|
|
/** |
|
23
|
|
|
* @var \eZ\Publish\Core\Persistence\Cache\InMemory\MetadataCachePool |
|
24
|
|
|
*/ |
|
25
|
|
|
protected $inMemoryPool; |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* Setups current handler with everything needed. |
|
29
|
|
|
* |
|
30
|
|
|
* @param \Symfony\Component\Cache\Adapter\TagAwareAdapterInterface $cache |
|
31
|
|
|
* @param \eZ\Publish\SPI\Persistence\Handler $persistenceHandler |
|
32
|
|
|
* @param \eZ\Publish\Core\Persistence\Cache\PersistenceLogger $logger |
|
33
|
|
|
*/ |
|
34
|
|
|
public function __construct( |
|
35
|
|
|
TagAwareAdapterInterface $cache, |
|
36
|
|
|
PersistenceHandler $persistenceHandler, |
|
37
|
|
|
PersistenceLogger $logger, |
|
38
|
|
|
MetadataCachePool $inMemoryPool |
|
39
|
|
|
) { |
|
40
|
|
|
parent::__construct($cache, $persistenceHandler, $logger); |
|
41
|
|
|
$this->inMemoryPool = $inMemoryPool; |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* Adds in-memory cache handling to {@see getMultipleCacheValues()}. |
|
46
|
|
|
*/ |
|
47
|
|
|
final protected function getMultipleInMemoryCacheValues( |
|
48
|
|
|
array $ids, |
|
49
|
|
|
string $keyPrefix, |
|
50
|
|
|
callable $missingFn, |
|
51
|
|
|
callable $taggingFn, |
|
52
|
|
|
callable $secondayIndexFn |
|
53
|
|
|
): array { |
|
54
|
|
|
$list = []; |
|
55
|
|
|
foreach ($ids as $index => $id) { |
|
56
|
|
|
if ($object = $this->inMemoryPool->get($keyPrefix . $id)) { |
|
|
|
|
|
|
57
|
|
|
$list[$id] = $object; |
|
58
|
|
|
unset($ids[$index]); |
|
59
|
|
|
} |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
if (empty($ids)) { |
|
63
|
|
|
return $list; |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
foreach (parent::getMultipleCacheItems($ids, $keyPrefix, $missingFn, $taggingFn) as $id => $object) { |
|
|
|
|
|
|
67
|
|
|
$list[$id] = $object; |
|
68
|
|
|
$this->inMemoryPool->set($keyPrefix . $id, $object, $secondayIndexFn($object)); |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
return $list; |
|
72
|
|
|
} |
|
73
|
|
|
} |
|
74
|
|
|
|
This check looks for function or method calls that always return null and whose return value is assigned to a variable.
The method
getObject()can return nothing but null, so it makes no sense to assign that value to a variable.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.