-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathDataLoaderInterface.php
74 lines (66 loc) · 1.87 KB
/
DataLoaderInterface.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<?php
/*
* This file is part of the DataLoaderPhp package.
*
* (c) Overblog <http://github.com/overblog/>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Overblog\DataLoader;
interface DataLoaderInterface
{
/**
* Loads a key, returning a `Promise` for the value represented by that key.
*
* @param mixed $key
*
* @return mixed return a Promise
*/
public function load($key);
/**
* Loads multiple keys, promising an array of values:
*
* list($a, $b) = $myLoader->loadMany(['a', 'b']);
*
* This is equivalent to the more verbose:
*
* list($a, $b) = \React\Promise\all([
* $myLoader->load('a'),
* $myLoader->load('b')
* ]);
* @param array $keys
*
* @return mixed return a Promise
*/
public function loadMany($keys);
/**
* Clears the value at `key` from the cache, if it exists.
*
* @param $key
* @return $this
*/
public function clear($key);
/**
* Clears the entire cache. To be used when some event results in unknown
* invalidations across this particular `DataLoader`.
*
* @return $this
*/
public function clearAll();
/**
* Adds the provided key and value to the cache. If the key already exists, no
* change is made. Returns itself for method chaining.
* @param $key
* @param $value
* @return $this
*/
public function prime($key, $value);
/**
* @param $promise
* @param bool $unwrap controls whether or not the value of the promise is returned for a fulfilled promise or if an exception is thrown if the promise is rejected
* @return mixed
* @throws \Exception
*/
public static function await($promise = null, $unwrap = true);
}