1 | <?php |
||
16 | class EntityIdForQueryCache { |
||
17 | |||
18 | const CACHE_ID_PREFIX = 'wikibase-store-entityforquery-'; |
||
19 | |||
20 | const CACHE_LIFE_TIME = 86400; |
||
21 | |||
22 | /** |
||
23 | * @var Cache |
||
24 | */ |
||
25 | private $cache; |
||
26 | |||
27 | /** |
||
28 | * @var int |
||
29 | */ |
||
30 | private $lifeTime; |
||
31 | |||
32 | /** |
||
33 | * @param Cache $cache |
||
34 | * @param int $lifeTime |
||
35 | */ |
||
36 | 6 | public function __construct( Cache $cache, $lifeTime = 0 ) { |
|
40 | |||
41 | /** |
||
42 | * @param Description $description |
||
43 | * @param QueryOptions $queryOptions |
||
44 | * @param string $entityType |
||
45 | * @return EntityId[] |
||
46 | */ |
||
47 | 4 | public function fetch( Description $description, QueryOptions $queryOptions = null, $entityType ) { |
|
48 | 4 | $result = $this->cache->fetch( $this->getCacheId( $description, $queryOptions, $entityType ) ); |
|
49 | |||
50 | 4 | if( $result === false ) { |
|
51 | 2 | throw new OutOfBoundsException( 'The search is not in the cache.' ); |
|
52 | } |
||
53 | |||
54 | 2 | return $result; |
|
55 | } |
||
56 | |||
57 | /** |
||
58 | * @param Description $description |
||
59 | * @param QueryOptions $queryOptions |
||
60 | * @param string $entityType |
||
61 | * @return boolean |
||
62 | */ |
||
63 | 2 | public function contains( Description $description, QueryOptions $queryOptions = null, $entityType ) { |
|
66 | |||
67 | /** |
||
68 | * @param Description $description |
||
69 | * @param QueryOptions $queryOptions |
||
70 | * @param string $entityType |
||
71 | * @param EntityId[] $entityIds |
||
72 | */ |
||
73 | 4 | public function save( Description $description, QueryOptions $queryOptions = null, $entityType, array $entityIds ) { |
|
82 | |||
83 | 6 | private function getCacheId( Description $description, QueryOptions $queryOptions = null, $entityType ) { |
|
93 | } |
||
94 |