|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Wikibase\EntityStore\Cache; |
|
4
|
|
|
|
|
5
|
|
|
use Doctrine\Common\Cache\Cache; |
|
6
|
|
|
use Wikibase\EntityStore\EntityStore; |
|
7
|
|
|
|
|
8
|
|
|
/** |
|
9
|
|
|
* @licence GPLv2+ |
|
10
|
|
|
* @author Thomas Pellissier Tanon |
|
11
|
|
|
*/ |
|
12
|
|
|
class CachedEntityStore extends EntityStore { |
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* @var EntityStore |
|
16
|
|
|
*/ |
|
17
|
|
|
private $entityStore; |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* @var EntityDocumentCache |
|
21
|
|
|
*/ |
|
22
|
|
|
private $entityCache; |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* @var EntityIdForTermCache |
|
26
|
|
|
*/ |
|
27
|
|
|
private $entityIdForTermCache; |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* @var EntityIdForQueryCache |
|
31
|
|
|
*/ |
|
32
|
|
|
private $entityIdForQueryCache; |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* @param EntityStore $entityStore |
|
36
|
|
|
* @param Cache $cache |
|
37
|
|
|
* @param int $lifeTime |
|
38
|
|
|
*/ |
|
39
|
11 |
|
public function __construct( EntityStore $entityStore, Cache $cache, $lifeTime = 0 ) { |
|
40
|
11 |
|
parent::__construct(); |
|
41
|
|
|
|
|
42
|
11 |
|
$this->entityStore = $entityStore; |
|
43
|
11 |
|
$this->entityCache = new EntityDocumentCache( $cache, $lifeTime ); |
|
44
|
11 |
|
$this->entityIdForTermCache = new EntityIdForTermCache( $cache, $lifeTime ); |
|
45
|
11 |
|
$this->entityIdForQueryCache = new EntityIdForQueryCache( $cache, $lifeTime ); |
|
46
|
11 |
|
} |
|
47
|
|
|
|
|
48
|
|
|
/** |
|
49
|
|
|
* @see EntityStore::getEntityDocumentLookup |
|
50
|
|
|
*/ |
|
51
|
2 |
|
public function getEntityDocumentLookup() { |
|
52
|
2 |
|
return new CachedEntityDocumentLookup( $this->entityStore->getEntityDocumentLookup(), $this->entityCache ); |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* @see EntityStore::getItemLookup |
|
57
|
|
|
*/ |
|
58
|
2 |
|
public function getItemLookup() { |
|
59
|
2 |
|
return new CachedItemLookup( $this->entityStore->getItemLookup(), $this->entityCache ); |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
/** |
|
63
|
|
|
* @see EntityStore::getPropertyLookup |
|
64
|
|
|
*/ |
|
65
|
2 |
|
public function getPropertyLookup() { |
|
66
|
2 |
|
return new CachedPropertyLookup( $this->entityStore->getPropertyLookup(), $this->entityCache ); |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
/** |
|
70
|
|
|
* @see EntityStore::getEntityDocumentSaver |
|
71
|
|
|
*/ |
|
72
|
2 |
|
public function getEntityDocumentSaver() { |
|
73
|
2 |
|
return $this->entityStore->getEntityDocumentSaver(); |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
/** |
|
77
|
|
|
* @see EntityStore::getItemIdForTermLookup |
|
78
|
|
|
*/ |
|
79
|
2 |
|
public function getItemIdForTermLookup() { |
|
80
|
2 |
|
return new CachedItemIdForTermLookup( $this->entityStore->getItemIdForTermLookup(), $this->entityIdForTermCache ); |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
/** |
|
84
|
|
|
* @see EntityStore::getPropertyIdForTermLookup |
|
85
|
|
|
*/ |
|
86
|
2 |
|
public function getPropertyIdForTermLookup() { |
|
87
|
2 |
|
return new CachedPropertyIdForTermLookup( $this->entityStore->getPropertyIdForTermLookup(), $this->entityIdForTermCache ); |
|
88
|
|
|
} |
|
89
|
|
|
|
|
90
|
|
|
/** |
|
91
|
|
|
* @see EntityStore::getItemIdForQueryLookup |
|
92
|
|
|
*/ |
|
93
|
2 |
|
public function getItemIdForQueryLookup() { |
|
94
|
2 |
|
return new CachedItemIdForQueryLookup( $this->entityStore->getItemIdForQueryLookup(), $this->entityIdForQueryCache ); |
|
95
|
|
|
} |
|
96
|
|
|
|
|
97
|
|
|
/** |
|
98
|
|
|
* @see EntityStore::getPropertyIdForQueryLookup |
|
99
|
|
|
*/ |
|
100
|
2 |
|
public function getPropertyIdForQueryLookup() { |
|
101
|
2 |
|
return $this->entityStore->getPropertyIdForQueryLookup(); |
|
102
|
|
|
} |
|
103
|
|
|
|
|
104
|
|
|
/** |
|
105
|
|
|
* @see EntityStore::setupStore |
|
106
|
|
|
*/ |
|
107
|
2 |
|
public function setupStore() { |
|
108
|
2 |
|
$this->entityStore->setupStore(); |
|
109
|
2 |
|
} |
|
110
|
|
|
|
|
111
|
|
|
/** |
|
112
|
|
|
* @see EntityStore::setupIndexes |
|
113
|
|
|
*/ |
|
114
|
2 |
|
public function setupIndexes() { |
|
115
|
2 |
|
$this->entityStore->setupIndexes(); |
|
116
|
2 |
|
} |
|
117
|
|
|
} |
|
118
|
|
|
|