Class | Line # | Actions | |||||
---|---|---|---|---|---|---|---|
DocumentCache | 37 | 0 | - | 0 | 0 |
1 | /* | |
2 | * See the NOTICE file distributed with this work for additional | |
3 | * information regarding copyright ownership. | |
4 | * | |
5 | * This is free software; you can redistribute it and/or modify it | |
6 | * under the terms of the GNU Lesser General Public License as | |
7 | * published by the Free Software Foundation; either version 2.1 of | |
8 | * the License, or (at your option) any later version. | |
9 | * | |
10 | * This software is distributed in the hope that it will be useful, | |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 | * Lesser General Public License for more details. | |
14 | * | |
15 | * You should have received a copy of the GNU Lesser General Public | |
16 | * License along with this software; if not, write to the Free | |
17 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | |
18 | * 02110-1301 USA, or see the FSF site: http://www.fsf.org. | |
19 | */ | |
20 | package com.xpn.xwiki.internal.cache; | |
21 | ||
22 | import org.xwiki.cache.CacheException; | |
23 | import org.xwiki.cache.config.CacheConfiguration; | |
24 | import org.xwiki.component.annotation.ComponentRole; | |
25 | import org.xwiki.model.reference.DocumentReference; | |
26 | ||
27 | /** | |
28 | * Specialized cache component related to documents. | |
29 | * | |
30 | * @param <C> the class of the data stored in the cache. | |
31 | * @version $Id: 1c96023cfc6db3e977e6a4defe5dee258f666e80 $ | |
32 | * @since 2.4M1 | |
33 | */ | |
34 | // Note: We cannot replace @ComponentRole with @Role ATM since @Role supports generics and we have DocumentCache<C>. | |
35 | // Changing it will thus break all code looking up components implementing this role. | |
36 | @ComponentRole | |
37 | public interface DocumentCache<C> | |
38 | { | |
39 | /** | |
40 | * Initialize the cache. | |
41 | * <p> | |
42 | * This method should be called before anything else. | |
43 | * | |
44 | * @param cacheConfiguration the cache configuration | |
45 | * @throws CacheException failed to initialize the cache | |
46 | */ | |
47 | void create(CacheConfiguration cacheConfiguration) throws CacheException; | |
48 | ||
49 | /** | |
50 | * Get the value associated with the provided key. | |
51 | * | |
52 | * @param documentReference the reference of the document | |
53 | * @param extensions the extensions to the document reference | |
54 | * @return the value | |
55 | */ | |
56 | C get(DocumentReference documentReference, Object... extensions); | |
57 | ||
58 | /** | |
59 | * Add a new value or overwrite the existing one associated with the provided key. | |
60 | * | |
61 | * @param data the data to store | |
62 | * @param documentReference the reference of the document | |
63 | * @param extensions the extensions to the document reference | |
64 | */ | |
65 | void set(C data, DocumentReference documentReference, Object... extensions); | |
66 | ||
67 | /** | |
68 | * Remove from the cache the value associated to the provided key elements. | |
69 | * | |
70 | * @param data the data to store | |
71 | * @param documentReference the reference of the document | |
72 | * @param extensions the extensions to the document reference | |
73 | */ | |
74 | void remove(C data, DocumentReference documentReference, Object... extensions); | |
75 | ||
76 | /** | |
77 | * Remove all the entries the cache contains. | |
78 | */ | |
79 | void removeAll(); | |
80 | ||
81 | /** | |
82 | * Remove all the entries the cache contains for specified document. | |
83 | * | |
84 | * @param documentReference document reference of cached document | |
85 | */ | |
86 | void removeAll(DocumentReference documentReference); | |
87 | ||
88 | /** | |
89 | * Release all the resources this cache use. | |
90 | */ | |
91 | void dispose(); | |
92 | } |