Skip to content

Package: Cache

Cache

Coverage

1: /**
2: * Copyright (C) 2016 Czech Technical University in Prague
3: *
4: * This program is free software: you can redistribute it and/or modify it under
5: * the terms of the GNU General Public License as published by the Free Software
6: * Foundation, either version 3 of the License, or (at your option) any
7: * later version.
8: *
9: * This program is distributed in the hope that it will be useful, but WITHOUT
10: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11: * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
12: * details. You should have received a copy of the GNU General Public License
13: * along with this program. If not, see <http://www.gnu.org/licenses/>.
14: */
15: package cz.cvut.kbss.jopa.sessions;
16:
17: import cz.cvut.kbss.jopa.model.descriptors.Descriptor;
18:
19: import java.net.URI;
20:
21: /**
22: * Interface used to interact with the second-level cache.
23: * <p>
24: * If a cache is not in use, the methods of this interface have no effect, except for contains, which
25: * returns false.
26: * <p>
27: * Taken from JPA 2.
28: */
29: public interface Cache {
30:
31: /**
32: * Checks whether the cache contains data for the given entity.
33: *
34: * @param cls Entity class
35: * @param identifier Instance identifier
36: * @param descriptor Specifies instance context and additional possible information, e.g. language tags
37: * @return {@code boolean} indicating whether the entity is in the cache
38: */
39: boolean contains(Class<?> cls, Object identifier, Descriptor descriptor);
40:
41: /**
42: * Removes the data for the given entity from the cache.
43: *
44: * @param cls Entity class
45: * @param identifier Instance identifier
46: * @param context Context URI, possibly {@code null}, meaning the default context
47: */
48: void evict(Class<?> cls, Object identifier, URI context);
49:
50: /**
51: * Removes the data for entities of the specified class (and its subclasses) from the cache.
52: * <p>
53: * This method removes the entities from all available contexts.
54: *
55: * @param cls entity class
56: */
57: void evict(Class<?> cls);
58:
59: /**
60: * Removes the data for entities of the specified repository context from the cache.
61: *
62: * @param context URI of the context to evict, possibly {@code null}, meaning the default context
63: */
64: void evict(URI context);
65:
66: /**
67: * Clears the cache.
68: */
69: void evictAll();
70: }