Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | n/a |
0 / 0 |
n/a |
0 / 0 |
CRAP | n/a |
0 / 0 |
|||
| 1 | <?php |
| 2 | /** |
| 3 | * |
| 4 | * This file is part of the phpBB Forum Software package. |
| 5 | * |
| 6 | * @copyright (c) phpBB Limited <https://www.phpbb.com> |
| 7 | * @license GNU General Public License, version 2 (GPL-2.0) |
| 8 | * |
| 9 | * For full copyright and license information, please see |
| 10 | * the docs/CREDITS.txt file. |
| 11 | * |
| 12 | */ |
| 13 | |
| 14 | namespace phpbb\cache\driver; |
| 15 | |
| 16 | /** |
| 17 | * An interface that all cache drivers must implement |
| 18 | */ |
| 19 | interface driver_interface |
| 20 | { |
| 21 | /** |
| 22 | * Load global cache |
| 23 | * |
| 24 | * @return mixed False if an error was encountered, otherwise the data type of the cached data |
| 25 | */ |
| 26 | public function load(); |
| 27 | |
| 28 | /** |
| 29 | * Unload cache object |
| 30 | * |
| 31 | * @return null |
| 32 | */ |
| 33 | public function unload(); |
| 34 | |
| 35 | /** |
| 36 | * Save modified objects |
| 37 | * |
| 38 | * @return null |
| 39 | */ |
| 40 | public function save(); |
| 41 | |
| 42 | /** |
| 43 | * Tidy cache |
| 44 | * |
| 45 | * @return null |
| 46 | */ |
| 47 | public function tidy(); |
| 48 | |
| 49 | /** |
| 50 | * Get saved cache object |
| 51 | * |
| 52 | * @param string $var_name Cache key |
| 53 | * @return mixed False if an error was encountered, otherwise the saved cached object |
| 54 | */ |
| 55 | public function get($var_name); |
| 56 | |
| 57 | /** |
| 58 | * Put data into cache |
| 59 | * |
| 60 | * @param string $var_name Cache key |
| 61 | * @param mixed $var Cached data to store |
| 62 | * @param int $ttl Time-to-live of cached data |
| 63 | * @return null |
| 64 | */ |
| 65 | public function put($var_name, $var, $ttl = 0); |
| 66 | |
| 67 | /** |
| 68 | * Purge cache data |
| 69 | * |
| 70 | * @return null |
| 71 | */ |
| 72 | public function purge(); |
| 73 | |
| 74 | /** |
| 75 | * Destroy cache data |
| 76 | * |
| 77 | * @param string $var_name Cache key |
| 78 | * @param string $table Table name |
| 79 | * @return null |
| 80 | */ |
| 81 | public function destroy($var_name, $table = ''); |
| 82 | |
| 83 | /** |
| 84 | * Check if a given cache entry exists |
| 85 | * |
| 86 | * @param string $var_name Cache key |
| 87 | * |
| 88 | * @return bool True if cache file exists and has not expired. |
| 89 | * False otherwise. |
| 90 | */ |
| 91 | public function _exists($var_name); |
| 92 | |
| 93 | /** |
| 94 | * Load result of an SQL query from cache. |
| 95 | * |
| 96 | * @param string $query SQL query |
| 97 | * |
| 98 | * @return string|false Query ID (md5 of query) if cache contains a rowset |
| 99 | * for the specified query. |
| 100 | * False otherwise. |
| 101 | */ |
| 102 | public function sql_load($query); |
| 103 | |
| 104 | /** |
| 105 | * Save result of an SQL query in cache. |
| 106 | * |
| 107 | * In persistent cache stores, this function stores the query |
| 108 | * result to persistent storage. In other words, there is no need |
| 109 | * to call save() afterwards. |
| 110 | * |
| 111 | * @param \phpbb\db\driver\driver_interface $db Database connection |
| 112 | * @param string $query SQL query, should be used for generating storage key |
| 113 | * @param mixed $query_result The result from \dbal::sql_query, to be passed to |
| 114 | * \dbal::sql_fetchrow to get all rows and store them |
| 115 | * in cache. |
| 116 | * @param int $ttl Time to live, after this timeout the query should |
| 117 | * expire from the cache. |
| 118 | * @return int|mixed If storing in cache succeeded, an integer $query_id |
| 119 | * representing the query should be returned. Otherwise |
| 120 | * the original $query_result should be returned. |
| 121 | */ |
| 122 | public function sql_save(\phpbb\db\driver\driver_interface $db, $query, $query_result, $ttl); |
| 123 | |
| 124 | /** |
| 125 | * Check if result for a given SQL query exists in cache. |
| 126 | * |
| 127 | * @param int $query_id |
| 128 | * @return bool |
| 129 | */ |
| 130 | public function sql_exists($query_id); |
| 131 | |
| 132 | /** |
| 133 | * Fetch row from cache (database) |
| 134 | * |
| 135 | * @param int $query_id |
| 136 | * @return array|bool The query result if found in the cache, otherwise |
| 137 | * false. |
| 138 | */ |
| 139 | public function sql_fetchrow($query_id); |
| 140 | |
| 141 | /** |
| 142 | * Fetch a field from the current row of a cached database result (database) |
| 143 | * |
| 144 | * @param int $query_id |
| 145 | * @param string $field The name of the column. |
| 146 | * @return string|bool The field of the query result if found in the cache, |
| 147 | * otherwise false. |
| 148 | */ |
| 149 | public function sql_fetchfield($query_id, $field); |
| 150 | |
| 151 | /** |
| 152 | * Seek a specific row in an a cached database result (database) |
| 153 | * |
| 154 | * @param int $rownum Row to seek to. |
| 155 | * @param int $query_id |
| 156 | * @return bool |
| 157 | */ |
| 158 | public function sql_rowseek($rownum, $query_id); |
| 159 | |
| 160 | /** |
| 161 | * Free memory used for a cached database result (database) |
| 162 | * |
| 163 | * @param int $query_id |
| 164 | * @return bool |
| 165 | */ |
| 166 | public function sql_freeresult($query_id); |
| 167 | |
| 168 | /** |
| 169 | * Ensure query ID can be used by cache |
| 170 | * |
| 171 | * @param object|resource|int|string $query_id Mixed type query id |
| 172 | * |
| 173 | * @return int|string Query id in string or integer format |
| 174 | */ |
| 175 | public function clean_query_id($query_id); |
| 176 | } |