Merge "Added a separate error message for mkdir failures"
[lhc/web/wiklou.git] / includes / cache / localisation / LCStore.php
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 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 of 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 interface LCStore {
39
40 /**
41 * Get a value.
42 * @param string $code Language code
43 * @param string $key Cache key
44 */
45 function get( $code, $key );
46
47 /**
48 * Start a write transaction.
49 * @param string $code Language code
50 */
51 function startWrite( $code );
52
53 /**
54 * Finish a write transaction.
55 */
56 function finishWrite();
57
58 /**
59 * Set a key to a given value. startWrite() must be called before this
60 * is called, and finishWrite() must be called afterwards.
61 * @param string $key
62 * @param mixed $value
63 */
64 function set( $key, $value );
65
66 }