Skip to content

Package: CacheManager

CacheManager

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 java.net.URI;
18: import java.util.Set;
19:
20: /**
21: * This interface defines basic methods for accessing the shared live object cache.
22: *
23: * @author kidney
24: */
25: public interface CacheManager extends Cache {
26:
27: /**
28: * Adds the specified object into the shared session cache. </p>
29: * <p>
30: * If the cache already contains object with the specified primary key (and it is in the same repository context),
31: * it is replaced with the one passed as argument.
32: *
33: * @param primaryKey Primary key of the specified object
34: * @param entity The object to be added into the cache
35: * @param context Repository context URI
36: */
37: void add(Object primaryKey, Object entity, URI context);
38:
39: /**
40: * Gets entity with the specified primary key from the cache. </p>
41: * <p>
42: * The entity is searched for in the context specified by {@code entityOrigin} . Thus all three conditions - class,
43: * primary key and origin must match to return a result.
44: *
45: * @param cls Class of the entity
46: * @param primaryKey Primary key of the entity
47: * @param context Repository context URI
48: * @return Entity with the specified primary key or {@code null}
49: */
50: <T> T get(Class<T> cls, Object primaryKey, URI context);
51:
52: /**
53: * Remove objects with inferred attributes from the cache, since there are changes in the ontology that might
54: * influence the inferred attributes.
55: */
56: void clearInferredObjects();
57:
58: /**
59: * Set the inferred classes for this cache manager. </p>
60: * <p>
61: * Entities from inferred classes are special in that when anything in the ontology changes, they have to be evicted
62: * from the cache, since they are reasoned and their attributes may change.
63: *
64: * @param inferredClasses Set of inferred classes
65: */
66: void setInferredClasses(Set<Class<?>> inferredClasses);
67:
68: /**
69: * Closes the cache.
70: */
71: void close();
72: }