1 | <?php |
||
10 | class Memcached extends \Memcached |
||
11 | { |
||
12 | /** |
||
13 | * @const ERR_SERVER_INFOS_FORMAT Exception code if server informations is |
||
14 | * not in a correct format. |
||
15 | */ |
||
16 | const ERR_SERVER_INFOS_FORMAT = 1309001; |
||
17 | |||
18 | /** |
||
19 | * @const ERR_NO_SERVER_CONNECTED Exception code if no server is connected. |
||
20 | */ |
||
21 | const ERR_NO_SERVER_CONNECTED = 1309002; |
||
22 | |||
23 | /** |
||
24 | * @const ERR_A_SERVER_IS_NOT_CONNECTED Exception code if a server is not |
||
25 | * connected. |
||
26 | */ |
||
27 | const ERR_A_SERVER_IS_NOT_CONNECTED = 1309003; |
||
28 | |||
29 | /** |
||
30 | * @const ERR_IFEXISTS_PARAM_TYPE Exception code if a parameter type is not |
||
31 | * correct into the method ifExists(). |
||
32 | */ |
||
33 | const ERR_IFEXISTS_PARAM_TYPE = 1309004; |
||
34 | |||
35 | /** |
||
36 | * @const ERR_UPDATEEXPIRE_PARAM_TYPE Exception code if a parameter type |
||
37 | * is not correct into the method updateExpire(). |
||
38 | */ |
||
39 | const ERR_UPDATEEXPIRE_PARAM_TYPE = 1309005; |
||
40 | |||
41 | /** |
||
42 | * @const ERR_KEY_NOT_EXIST Exception code if the asked key not exist. |
||
43 | * Actually only used into the method updateExpire(). |
||
44 | */ |
||
45 | const ERR_KEY_NOT_EXIST = 1309006; |
||
46 | |||
47 | /** |
||
48 | * @var array $config Config define into bfw config file for memcache(d) |
||
49 | */ |
||
50 | protected $config; |
||
51 | |||
52 | /** |
||
53 | * Constructor. |
||
54 | * Call parent constructor with the persistentId if declared in config |
||
55 | * Connect to servers. |
||
56 | */ |
||
57 | public function __construct() |
||
71 | |||
72 | /** |
||
73 | * Get accessor to the property config |
||
74 | * |
||
75 | * @return array |
||
76 | */ |
||
77 | public function getConfig() |
||
81 | |||
82 | /** |
||
83 | * Get the list of server already connected (persistent) |
||
84 | * Loop on server declared into the config file. |
||
85 | * Connect to server if not already connected |
||
86 | * |
||
87 | * @return void |
||
88 | */ |
||
89 | public function connectToServers() |
||
136 | |||
137 | /** |
||
138 | * Get the list of servers where we are already connected (persistent) |
||
139 | * |
||
140 | * @return string[] |
||
141 | */ |
||
142 | protected function generateServerList() |
||
153 | /** |
||
154 | * Read the server information and add not existing keys |
||
155 | * |
||
156 | * @param array &$infos Server informations |
||
157 | * |
||
158 | * @return void |
||
159 | * |
||
160 | * @throw \Exception If informations datas is not an array |
||
161 | */ |
||
162 | protected function completeServerInfos(&$infos) |
||
185 | |||
186 | /** |
||
187 | * addServer not created the connection. It's created at the first call |
||
188 | * to the memcached servers. |
||
189 | * |
||
190 | * So, we run the connect to all server declared |
||
191 | * |
||
192 | * @throws \Exception If a server is not connected |
||
193 | * |
||
194 | * @return boolean |
||
195 | */ |
||
196 | protected function testConnect() |
||
218 | |||
219 | /** |
||
220 | * Check if a key exists into memcache(d) |
||
221 | * /!\ Not work if the correct value is the boolean false /!\ |
||
222 | * |
||
223 | * @param string $key The memcache(d) key to check |
||
224 | * |
||
225 | * @return boolean |
||
226 | * |
||
227 | * @throws Exception If the key is not a string |
||
228 | */ |
||
229 | public function ifExists($key) |
||
252 | |||
253 | /** |
||
254 | * Update the expire time for a memcache(d) key. |
||
255 | * |
||
256 | * @param string $key The memcache(d) key to update |
||
257 | * @param int $expire The new expire time |
||
258 | * |
||
259 | * @return boolean |
||
260 | * |
||
261 | * @throws Exception |
||
262 | */ |
||
263 | public function updateExpire($key, $expire) |
||
290 | } |
||
291 |
If you implement
__call
and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.This is often the case, when
__call
is implemented by a parent class and only the child class knows which methods exist: