| 1 | <?php |
| 2 | /** |
| 3 | * This program is free software; you can redistribute it and/or modify |
| 4 | * it under the terms of the GNU General Public License as published by |
| 5 | * the Free Software Foundation; either version 2 of the License, or |
| 6 | * (at your option) any later version. |
| 7 | * |
| 8 | * This program is distributed in the hope that it will be useful, |
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 | * GNU General Public License for more details. |
| 12 | * |
| 13 | * You should have received a copy of the GNU General Public License along |
| 14 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 15 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 16 | * http://www.gnu.org/copyleft/gpl.html |
| 17 | * |
| 18 | * @file |
| 19 | */ |
| 20 | |
| 21 | /** |
| 22 | * Interface for the persistence layer of LocalisationCache. |
| 23 | * |
| 24 | * The persistence layer is a two-level hierarchical cache. The first level |
| 25 | * is the language, the second level is the item or subitem. |
| 26 | * |
| 27 | * Since the data for a whole language is rebuilt in one operation, it needs |
| 28 | * to have a fast and atomic method for deleting or replacing all the |
| 29 | * current data for a given language. The interface reflects this bulk update |
| 30 | * operation. Callers writing to the cache must first call startWrite(), then |
| 31 | * will call set() a couple of thousand times, then will call finishWrite() |
| 32 | * to commit the operation. When finishWrite() is called, the cache is |
| 33 | * expected to delete all data previously stored for that language. |
| 34 | * |
| 35 | * The values stored are PHP variables suitable for serialize(). Implementations |
| 36 | * of LCStore are responsible for serializing and unserializing. |
| 37 | * |
| 38 | * @ingroup Language |
| 39 | */ |
| 40 | interface LCStore { |
| 41 | |
| 42 | /** |
| 43 | * Get a value. |
| 44 | * |
| 45 | * @param string $code Language code |
| 46 | * @param string $key Cache key |
| 47 | */ |
| 48 | public function get( $code, $key ); |
| 49 | |
| 50 | /** |
| 51 | * Start a cache write transaction. |
| 52 | * |
| 53 | * @param string $code Language code |
| 54 | */ |
| 55 | public function startWrite( $code ); |
| 56 | |
| 57 | /** |
| 58 | * Finish a cache write transaction. |
| 59 | */ |
| 60 | public function finishWrite(); |
| 61 | |
| 62 | /** |
| 63 | * Set a key to a given value. startWrite() must be called before this |
| 64 | * is called, and finishWrite() must be called after. |
| 65 | * |
| 66 | * @param string $key |
| 67 | * @param mixed $value |
| 68 | */ |
| 69 | public function set( $key, $value ); |
| 70 | |
| 71 | } |