memcache.phan_php 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460
  1. <?php
  2. // Start of memcache v.3.0.8
  3. class MemcachePool {
  4. /**
  5. * (PECL memcache &gt;= 0.2.0)<br/>
  6. * Open memcached server connection
  7. * @link https://php.net/manual/en/memcache.connect.php
  8. * @param string $host <p>
  9. * Point to the host where memcached is listening for connections. This parameter
  10. * may also specify other transports like <em>unix:///path/to/memcached.sock</em>
  11. * to use UNIX domain sockets, in this case <b>port</b> must also
  12. * be set to <em>0</em>.
  13. * </p>
  14. * @param int $port [optional] <p>
  15. * Point to the port where memcached is listening for connections. Set this
  16. * parameter to <em>0</em> when using UNIX domain sockets.
  17. * </p>
  18. * <p>
  19. * Please note: <b>port</b> defaults to
  20. * {@link https://php.net/manual/ru/memcache.ini.php#ini.memcache.default-port memcache.default_port}
  21. * if not specified. For this reason it is wise to specify the port
  22. * explicitly in this method call.
  23. * </p>
  24. * @param int $timeout [optional] <p>Value in seconds which will be used for connecting to the daemon. Think twice before changing the default value of 1 second - you can lose all the advantages of caching if your connection is too slow.</p>
  25. * @return bool <p>Returns <b>TRUE</b> on success or <b>FALSE</b> on failure.</p>
  26. */
  27. public function connect ($host, $port, $timeout = 1) {}
  28. /**
  29. * (PECL memcache &gt;= 2.0.0)<br/>
  30. * Add a memcached server to connection pool
  31. * @link https://php.net/manual/en/memcache.addserver.php
  32. * @param string $host <p>
  33. * Point to the host where memcached is listening for connections. This parameter
  34. * may also specify other transports like unix:///path/to/memcached.sock
  35. * to use UNIX domain sockets, in this case <i>port</i> must also
  36. * be set to 0.
  37. * </p>
  38. * @param int $port [optional] <p>
  39. * Point to the port where memcached is listening for connections.
  40. * Set this
  41. * parameter to 0 when using UNIX domain sockets.
  42. * </p>
  43. * <p>
  44. * Please note: <i>port</i> defaults to
  45. * memcache.default_port
  46. * if not specified. For this reason it is wise to specify the port
  47. * explicitly in this method call.
  48. * </p>
  49. * @param bool $persistent [optional] <p>
  50. * Controls the use of a persistent connection. Default to <b>TRUE</b>.
  51. * </p>
  52. * @param int $weight [optional] <p>
  53. * Number of buckets to create for this server which in turn control its
  54. * probability of it being selected. The probability is relative to the
  55. * total weight of all servers.
  56. * </p>
  57. * @param int $timeout [optional] <p>
  58. * Value in seconds which will be used for connecting to the daemon. Think
  59. * twice before changing the default value of 1 second - you can lose all
  60. * the advantages of caching if your connection is too slow.
  61. * </p>
  62. * @param int $retry_interval [optional] <p>
  63. * Controls how often a failed server will be retried, the default value
  64. * is 15 seconds. Setting this parameter to -1 disables automatic retry.
  65. * Neither this nor the <i>persistent</i> parameter has any
  66. * effect when the extension is loaded dynamically via <b>dl</b>.
  67. * </p>
  68. * <p>
  69. * Each failed connection struct has its own timeout and before it has expired
  70. * the struct will be skipped when selecting backends to serve a request. Once
  71. * expired the connection will be successfully reconnected or marked as failed
  72. * for another <i>retry_interval</i> seconds. The typical
  73. * effect is that each web server child will retry the connection about every
  74. * <i>retry_interval</i> seconds when serving a page.
  75. * </p>
  76. * @param bool $status [optional] <p>
  77. * Controls if the server should be flagged as online. Setting this parameter
  78. * to <b>FALSE</b> and <i>retry_interval</i> to -1 allows a failed
  79. * server to be kept in the pool so as not to affect the key distribution
  80. * algorithm. Requests for this server will then failover or fail immediately
  81. * depending on the <i>memcache.allow_failover</i> setting.
  82. * Default to <b>TRUE</b>, meaning the server should be considered online.
  83. * </p>
  84. * @param callable $failure_callback [optional] <p>
  85. * Allows the user to specify a callback function to run upon encountering an
  86. * error. The callback is run before failover is attempted. The function takes
  87. * two parameters, the hostname and port of the failed server.
  88. * </p>
  89. * @param int $timeoutms [optional] <p>
  90. * </p>
  91. * @return bool <b>TRUE</b> on success or <b>FALSE</b> on failure.
  92. */
  93. public function addServer ($host, $port = 11211, $persistent = true, $weight = null, $timeout = 1, $retry_interval = 15, $status = true, callable $failure_callback = null, $timeoutms = null) {}
  94. /**
  95. * (PECL memcache &gt;= 2.1.0)<br/>
  96. * Changes server parameters and status at runtime
  97. * @link https://secure.php.net/manual/en/memcache.setserverparams.php
  98. * @param string $host <p>Point to the host where memcached is listening for connections.</p.
  99. * @param int $port [optional] <p>
  100. * Point to the port where memcached is listening for connections.
  101. * </p>
  102. * @param int $timeout [optional] <p>
  103. * Value in seconds which will be used for connecting to the daemon. Think twice before changing the default value of 1 second - you can lose all the advantages of caching if your connection is too slow.
  104. * </p>
  105. * @param int $retry_interval [optional] <p>
  106. * Controls how often a failed server will be retried, the default value
  107. * is 15 seconds. Setting this parameter to -1 disables automatic retry.
  108. * Neither this nor the <b>persistent</b> parameter has any
  109. * effect when the extension is loaded dynamically via {@link https://secure.php.net/manual/en/function.dl.php dl()}.
  110. * </p>
  111. * @param bool $status [optional] <p>
  112. * Controls if the server should be flagged as online. Setting this parameter
  113. * to <b>FALSE</b> and <b>retry_interval</b> to -1 allows a failed
  114. * server to be kept in the pool so as not to affect the key distribution
  115. * algorithm. Requests for this server will then failover or fail immediately
  116. * depending on the <b>memcache.allow_failover</b> setting.
  117. * Default to <b>TRUE</b>, meaning the server should be considered online.
  118. * </p>
  119. * @param callable $failure_callback [optional] <p>
  120. * Allows the user to specify a callback function to run upon encountering an error. The callback is run before failover is attempted.
  121. * The function takes two parameters, the hostname and port of the failed server.
  122. * </p>
  123. * @return bool <p>Returns <b>TRUE</b> on success or <b>FALSE</b> on failure.</p>
  124. */
  125. public function setServerParams ($host, $port = 11211, $timeout = 1, $retry_interval = 15, $status = true, callable $failure_callback = null) {}
  126. /**
  127. *
  128. */
  129. public function setFailureCallback () {}
  130. /**
  131. * (PECL memcache &gt;= 2.1.0)<br/>
  132. * Returns server status
  133. * @link https://php.net/manual/en/memcache.getserverstatus.php
  134. * @param string $host Point to the host where memcached is listening for connections.
  135. * @param int $port Point to the port where memcached is listening for connections.
  136. * @return int Returns a the servers status. 0 if server is failed, non-zero otherwise
  137. */
  138. public function getServerStatus ($host, $port = 11211) {}
  139. /**
  140. *
  141. */
  142. public function findServer () {}
  143. /**
  144. * (PECL memcache &gt;= 0.2.0)<br/>
  145. * Return version of the server
  146. * @link https://php.net/manual/en/memcache.getversion.php
  147. * @return string|false Returns a string of server version number or <b>FALSE</b> on failure.
  148. */
  149. public function getVersion () {}
  150. /**
  151. * (PECL memcache &gt;= 2.0.0)<br/>
  152. * Add an item to the server. If the key already exists, the value will not be added and <b>FALSE</b> will be returned.
  153. * @link https://php.net/manual/en/memcache.add.php
  154. * @param string $key The key that will be associated with the item.
  155. * @param mixed $var The variable to store. Strings and integers are stored as is, other types are stored serialized.
  156. * @param int $flag [optional] <p>
  157. * Use <b>MEMCACHE_COMPRESSED</b> to store the item
  158. * compressed (uses zlib).
  159. * </p>
  160. * @param int $expire [optional] <p>Expiration time of the item.
  161. * If it's equal to zero, the item will never expire.
  162. * You can also use Unix timestamp or a number of seconds starting from current time, but in the latter case the number of seconds may not exceed 2592000 (30 days).</p>
  163. * @return bool Returns <b>TRUE</b> on success or <b>FALSE</b> on failure. Returns <b>FALSE</b> if such key already exist. For the rest Memcache::add() behaves similarly to Memcache::set().
  164. */
  165. public function add ($key , $var, $flag = null, $expire = null) {}
  166. /**
  167. * (PECL memcache &gt;= 0.2.0)<br/>
  168. * Stores an item var with key on the memcached server. Parameter expire is expiration time in seconds.
  169. * If it's 0, the item never expires (but memcached server doesn't guarantee this item to be stored all the time,
  170. * it could be deleted from the cache to make place for other items).
  171. * You can use MEMCACHE_COMPRESSED constant as flag value if you want to use on-the-fly compression (uses zlib).
  172. * @link https://php.net/manual/en/memcache.set.php
  173. * @param string $key The key that will be associated with the item.
  174. * @param mixed $var The variable to store. Strings and integers are stored as is, other types are stored serialized.
  175. * @param int $flag [optional] Use MEMCACHE_COMPRESSED to store the item compressed (uses zlib).
  176. * @param int $expire [optional] Expiration time of the item. If it's equal to zero, the item will never expire. You can also use Unix timestamp or a number of seconds starting from current time, but in the latter case the number of seconds may not exceed 2592000 (30 days).
  177. * @return bool Returns <b>TRUE</b> on success or <b>FALSE</b> on failure.
  178. */
  179. public function set ($key, $var, $flag = null, $expire = null) {}
  180. /**
  181. * (PECL memcache &gt;= 0.2.0)<br/>
  182. * Replace value of the existing item
  183. * @link https://php.net/manual/en/memcache.replace.php
  184. * @param string $key <p>The key that will be associated with the item.</p>
  185. * @param mixed $var <p>The variable to store. Strings and integers are stored as is, other types are stored serialized.</p>
  186. * @param int $flag [optional] <p>Use <b>MEMCACHE_COMPRESSED</b> to store the item compressed (uses zlib).</p>
  187. * @param int $expire [optional] <p>Expiration time of the item. If it's equal to zero, the item will never expire. You can also use Unix timestamp or a number of seconds starting from current time, but in the latter case the number of seconds may not exceed 2592000 (30 days).</p>
  188. * @return bool Returns TRUE on success or FALSE on failure.
  189. */
  190. public function replace ($key, $var, $flag = null, $expire = null) {}
  191. public function cas () {}
  192. public function append () {}
  193. /**
  194. * @return string
  195. */
  196. public function prepend () {}
  197. /**
  198. * (PECL memcache &gt;= 0.2.0)<br/>
  199. * Retrieve item from the server
  200. * @link https://php.net/manual/en/memcache.get.php
  201. * @param string|array $key <p>
  202. * The key or array of keys to fetch.
  203. * </p>
  204. * @param int|array $flags [optional] <p>
  205. * If present, flags fetched along with the values will be written to this parameter. These
  206. * flags are the same as the ones given to for example {@link https://php.net/manual/en/memcache.set.php Memcache::set()}.
  207. * The lowest byte of the int is reserved for pecl/memcache internal usage (e.g. to indicate
  208. * compression and serialization status).
  209. * </p>
  210. * @return string|array|false <p>
  211. * Returns the string associated with the <b>key</b> or
  212. * an array of found key-value pairs when <b>key</b> is an {@link https://php.net/manual/en/language.types.array.php array}.
  213. * Returns <b>FALSE</b> on failure, <b>key</b> is not found or
  214. * <b>key</b> is an empty {@link https://php.net/manual/en/language.types.array.php array}.
  215. * </p>
  216. */
  217. public function get ($key, &$flags = null) {}
  218. /**
  219. * (PECL memcache &gt;= 0.2.0)<br/>
  220. * Delete item from the server
  221. * https://secure.php.net/manual/ru/memcache.delete.php
  222. * @param $key string The key associated with the item to delete.
  223. * @param $timeout int [optional] This deprecated parameter is not supported, and defaults to 0 seconds. Do not use this parameter.
  224. * @return bool Returns <b>TRUE</b> on success or <b>FALSE</b> on failure.
  225. */
  226. public function delete ($key, $timeout = 0 ) {}
  227. /**
  228. * (PECL memcache &gt;= 0.2.0)<br/>
  229. * Get statistics of the server
  230. * @link https://php.net/manual/ru/memcache.getstats.php
  231. * @param string $type [optional] <p>
  232. * The type of statistics to fetch.
  233. * Valid values are {reset, malloc, maps, cachedump, slabs, items, sizes}.
  234. * According to the memcached protocol spec these additional arguments "are subject to change for the convenience of memcache developers".</p>
  235. * @param int $slabid [optional] <p>
  236. * Used in conjunction with <b>type</b> set to
  237. * cachedump to identify the slab to dump from. The cachedump
  238. * command ties up the server and is strictly to be used for
  239. * debugging purposes.
  240. * </p>
  241. * @param int $limit [optional] <p>
  242. * Used in conjunction with <b>type</b> set to cachedump to limit the number of entries to dump.
  243. * </p>
  244. * @return array|false Returns an associative array of server statistics or <b>FALSE</b> on failure.
  245. */
  246. public function getStats ($type = null, $slabid = null, $limit = 100) {}
  247. /**
  248. * (PECL memcache &gt;= 2.0.0)<br/>
  249. * Get statistics from all servers in pool
  250. * @link https://php.net/manual/en/memcache.getextendedstats.php
  251. * @param string $type [optional] <p>The type of statistics to fetch. Valid values are {reset, malloc, maps, cachedump, slabs, items, sizes}. According to the memcached protocol spec these additional arguments "are subject to change for the convenience of memcache developers".</p>
  252. * @param int $slabid [optional] <p>
  253. * Used in conjunction with <b>type</b> set to
  254. * cachedump to identify the slab to dump from. The cachedump
  255. * command ties up the server and is strictly to be used for
  256. * debugging purposes.
  257. * </p>
  258. * @param int $limit Used in conjunction with type set to cachedump to limit the number of entries to dump.
  259. * @return array|false Returns a two-dimensional associative array of server statistics or <b>FALSE</b>
  260. * Returns a two-dimensional associative array of server statistics or <b>FALSE</b>
  261. * on failure.
  262. */
  263. public function getExtendedStats ($type = null, $slabid = null, $limit = 100) {}
  264. /**
  265. * (PECL memcache &gt;= 2.0.0)<br/>
  266. * Enable automatic compression of large values
  267. * @link https://php.net/manual/en/memcache.setcompressthreshold.php
  268. * @param int $thresold <p>Controls the minimum value length before attempting to compress automatically.</p>
  269. * @param float $min_saving [optional] <p>Specifies the minimum amount of savings to actually store the value compressed. The supplied value must be between 0 and 1. Default value is 0.2 giving a minimum 20% compression savings.</p>
  270. * @return bool Returns <b>TRUE</b> on success or <b>FALSE</b> on failure.
  271. */
  272. public function setCompressThreshold ($thresold, $min_saving = 0.2) {}
  273. /**
  274. * (PECL memcache &gt;= 0.2.0)<br/>
  275. * Increment item's value
  276. * @link https://php.net/manual/en/memcache.increment.php
  277. * @param $key string Key of the item to increment.
  278. * @param $value int [optional] increment the item by <b>value</b>
  279. * @return int|false Returns new items value on success or <b>FALSE</b> on failure.
  280. */
  281. public function increment ($key, $value = 1) {}
  282. /**
  283. * (PECL memcache &gt;= 0.2.0)<br/>
  284. * Decrement item's value
  285. * @link https://php.net/manual/en/memcache.decrement.php
  286. * @param $key string Key of the item do decrement.
  287. * @param $value int Decrement the item by <b>value</b>.
  288. * @return int|false Returns item's new value on success or <b>FALSE</b> on failure.
  289. */
  290. public function decrement ($key, $value = 1) {}
  291. /**
  292. * (PECL memcache &gt;= 0.4.0)<br/>
  293. * Close memcached server connection
  294. * @link https://php.net/manual/en/memcache.close.php
  295. * @return bool Returns <b>TRUE</b> on success or <b>FALSE</b> on failure.
  296. */
  297. public function close () {}
  298. /**
  299. * (PECL memcache &gt;= 1.0.0)<br/>
  300. * Flush all existing items at the server
  301. * @link https://php.net/manual/en/memcache.flush.php
  302. * @return bool Returns <b>TRUE</b> on success or <b>FALSE</b> on failure.
  303. */
  304. public function flush () {}
  305. }
  306. /**
  307. * Represents a connection to a set of memcache servers.
  308. * @link https://php.net/manual/en/class.memcache.php
  309. */
  310. class Memcache extends MemcachePool {
  311. /**
  312. * (PECL memcache &gt;= 0.4.0)<br/>
  313. * Open memcached server persistent connection
  314. * @link https://php.net/manual/en/memcache.pconnect.php
  315. * @param string $host <p>
  316. * Point to the host where memcached is listening for connections. This parameter
  317. * may also specify other transports like unix:///path/to/memcached.sock
  318. * to use UNIX domain sockets, in this case <i>port</i> must also
  319. * be set to 0.
  320. * </p>
  321. * @param int $port [optional] <p>
  322. * Point to the port where memcached is listening for connections. Set this
  323. * parameter to 0 when using UNIX domain sockets.
  324. * </p>
  325. * @param int $timeout [optional] <p>
  326. * Value in seconds which will be used for connecting to the daemon. Think
  327. * twice before changing the default value of 1 second - you can lose all
  328. * the advantages of caching if your connection is too slow.
  329. * </p>
  330. * @return mixed a Memcache object or <b>FALSE</b> on failure.
  331. */
  332. public function pconnect ($host, $port, $timeout = 1) {}
  333. }
  334. // string $host [, int $port [, int $timeout ]]
  335. /**
  336. * (PECL memcache >= 0.2.0)</br>
  337. * Memcache::connect — Open memcached server connection
  338. * @link https://php.net/manual/en/memcache.connect.php
  339. * @param string $host <p>
  340. * Point to the host where memcached is listening for connections.
  341. * This parameter may also specify other transports like
  342. * unix:///path/to/memcached.sock to use UNIX domain sockets,
  343. * in this case port must also be set to 0.
  344. * </p>
  345. * @param int $port [optional] <p>
  346. * Point to the port where memcached is listening for connections.
  347. * Set this parameter to 0 when using UNIX domain sockets.
  348. * Note: port defaults to memcache.default_port if not specified.
  349. * For this reason it is wise to specify the port explicitly in this method call.
  350. * </p>
  351. * @param int $timeout [optional] <p>
  352. * Value in seconds which will be used for connecting to the daemon.
  353. * </p>
  354. * @return bool Returns <b>TRUE</b> on success or <b>FALSE</b> on failure.
  355. */
  356. function memcache_connect ($host, $port, $timeout = 1) {}
  357. /**
  358. * (PECL memcache >= 0.4.0)
  359. * Memcache::pconnect — Open memcached server persistent connection
  360. *
  361. * @link https://php.net/manual/en/memcache.pconnect.php#example-5242
  362. * @param $host
  363. * @param null $port
  364. * @param int $timeout
  365. * @return Memcache
  366. */
  367. function memcache_pconnect ($host, $port=null, $timeout=1) {}
  368. function memcache_add_server () {}
  369. function memcache_set_server_params () {}
  370. function memcache_set_failure_callback () {}
  371. function memcache_get_server_status () {}
  372. function memcache_get_version () {}
  373. function memcache_add () {}
  374. function memcache_set () {}
  375. function memcache_replace () {}
  376. function memcache_cas () {}
  377. function memcache_append () {}
  378. function memcache_prepend () {}
  379. function memcache_get () {}
  380. function memcache_delete () {}
  381. /**
  382. * (PECL memcache &gt;= 0.2.0)<br/>
  383. * Turn debug output on/off
  384. * @link https://php.net/manual/en/function.memcache-debug.php
  385. * @param bool $on_off <p>
  386. * Turns debug output on if equals to <b>TRUE</b>.
  387. * Turns debug output off if equals to <b>FALSE</b>.
  388. * </p>
  389. * @return bool <b>TRUE</b> if PHP was built with --enable-debug option, otherwise
  390. * returns <b>FALSE</b>.
  391. */
  392. function memcache_debug ($on_off) {}
  393. function memcache_get_stats () {}
  394. function memcache_get_extended_stats () {}
  395. function memcache_set_compress_threshold () {}
  396. function memcache_increment () {}
  397. function memcache_decrement () {}
  398. function memcache_close () {}
  399. function memcache_flush () {}
  400. define ('MEMCACHE_COMPRESSED', 2);
  401. define ('MEMCACHE_USER1', 65536);
  402. define ('MEMCACHE_USER2', 131072);
  403. define ('MEMCACHE_USER3', 262144);
  404. define ('MEMCACHE_USER4', 524288);
  405. define ('MEMCACHE_HAVE_SESSION', 1);
  406. // End of memcache v.3.0.8
  407. ?>