KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > versant > core > storagemanager > StorageCache


1
2 /*
3  * Copyright (c) 1998 - 2005 Versant Corporation
4  * All rights reserved. This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License v1.0
6  * which accompanies this distribution, and is available at
7  * http://www.eclipse.org/legal/epl-v10.html
8  *
9  * Contributors:
10  * Versant Corporation - initial API and implementation
11  */

12 package com.versant.core.storagemanager;
13
14 import com.versant.core.server.CachedQueryResult;
15 import com.versant.core.server.CompiledQuery;
16 import com.versant.core.metadata.FetchGroup;
17 import com.versant.core.metadata.ClassMetaData;
18 import com.versant.core.metadata.ModelMetaData;
19 import com.versant.core.common.OID;
20 import com.versant.core.common.State;
21 import com.versant.core.common.*;
22
23 /**
24  * Cache of State's and query results shared by multiple StorageManager's.
25  * A single class is used to cache both State's and query results so that
26  * query results can be efficiently evicted when States of classes they
27  * depend on are evicted. Only data read in a committed database transaction
28  * may be added to the cache.
29  */

30 public interface StorageCache {
31
32     /**
33      * This is invoked when the meta data is available.
34      */

35     public void setJDOMetaData(ModelMetaData jmd);
36
37     /**
38      * Is the cache enabled?
39      */

40     public boolean isEnabled();
41
42     /**
43      * Is query caching enabled?
44      */

45     public boolean isQueryCacheEnabled();
46
47     /**
48      * Begin a cache transaction and return an identifier for it. This
49      * must be called before a new database transaction is started.
50      */

51     public Object JavaDoc beginTx();
52
53     /**
54      * End a cache transaction.
55      */

56     public void endTx(Object JavaDoc tx);
57
58     /**
59      * Get the State for an OID or null if it is not in cache or does not
60      * contain the fields in the fetchGroup. This returns a copy of the
61      * data in the cache. If fetchGroup is null then if any state is
62      * present it is returned.
63      */

64     public State getState(OID oid, FetchGroup fetchGroup);
65
66     /**
67      * Does the cache contain any data for the oid? Note that the data could
68      * be evicted at any time.
69      */

70     public boolean contains(OID oid);
71
72     /**
73      * Get cached query results or null if there are none.
74      * @param cq
75      * @param params
76      */

77     public CachedQueryResult getQueryResult(CompiledQuery cq, Object JavaDoc[] params);
78
79     /**
80      * Get result count or -1 if there are none.
81      * @param cq
82      * @param params
83      */

84     public int getQueryResultCount(CompiledQuery cq, Object JavaDoc[] params);
85
86     /**
87      * Add all the states in the container to the cache.
88      */

89     public void add(Object JavaDoc tx, StatesReturned container);
90
91     /**
92      * Add query results to the cache.
93      */

94     public void add(Object JavaDoc tx, CompiledQuery cq, Object JavaDoc[] params,
95             CachedQueryResult queryData);
96
97     /**
98      * Add query result count to the cache.
99      */

100     public void add(Object JavaDoc tx, CompiledQuery cq, Object JavaDoc[] params, int count);
101
102     /**
103      * Evict length OIDs from oids starting at offset. Expected is the total
104      * number of OIDs we expect to evict in the transaction or 0 if this is
105      * not known. This may be used to optimize cache storage allocation.
106      */

107     public void evict(Object JavaDoc tx, OID[] oids, int offset, int length,
108             int expected);
109
110     /**
111      * Evict all data for the classes.
112      */

113     public void evict(Object JavaDoc tx, ClassMetaData[] classes, int classCount);
114
115     /**
116      * Evict all data.
117      */

118     public void evictAll(Object JavaDoc tx);
119
120     /**
121      * Evict any cached information for the query.
122      */

123     public void evict(Object JavaDoc tx, CompiledQuery cq, Object JavaDoc[] params);
124 }
125
126
Popular Tags