File D:\maven-qcr-plugin-testsunitaires\qcr4java\h2-1.3.170-sources\target\site\qc\lecode\util\Cache.java.html

1 /*
2 * Copyright 2004-2011 H2 Group. Multiple-Licensed under the H2 License,
3 * Version 1.0, and under the Eclipse Public License, Version 1.0
4 * (http://h2database.com/html/license.html).
5 * Initial Developer: H2 Group
6 */
7 package org.h2.util;
8
9 import java.util.ArrayList;
10
11 /**
12 * The cache keeps frequently used objects in the main memory.
13 */
14 public interface Cache {
15
16 /**
17 * Get all objects in the cache that have been changed.
18 *
19 * @return the list of objects
20 */
21 ArrayList<CacheObject> getAllChanged();
22
23 /**
24 * Clear the cache.
25 */
26 void clear();
27
28 /**
29 * Get an element in the cache if it is available.
30 * This will move the item to the front of the list.
31 *
32 * @param pos the unique key of the element
33 * @return the element or null
34 */
35 CacheObject get(int pos);
36
37 /**
38 * Add an element to the cache. Other items may fall out of the cache
39 * because of this. It is not allowed to add the same record twice.
40 *
41 * @param r the object
42 */
43 void put(CacheObject r);
44
45 /**
46 * Update an element in the cache.
47 * This will move the item to the front of the list.
48 *
49 * @param pos the unique key of the element
50 * @param record the element
51 * @return the element
52 */
53 CacheObject update(int pos, CacheObject record);
54
55 /**
56 * Remove an object from the cache.
57 *
58 * @param pos the unique key of the element
59 * @return true if the key was in the cache
60 */
61 boolean remove(int pos);
62
63 /**
64 * Get an element from the cache if it is available.
65 * This will not move the item to the front of the list.
66 *
67 * @param pos the unique key of the element
68 * @return the element or null
69 */
70 CacheObject find(int pos);
71
72 /**
73 * Set the maximum memory to be used by this cache.
74 *
75 * @param size the maximum size in KB
76 */
77 void setMaxMemory(int size);
78
79 /**
80 * Get the maximum memory to be used.
81 *
82 * @return the maximum size in KB
83 */
84 int getMaxMemory();
85
86 /**
87 * Get the used size in KB.
88 *
89 * @return the current size in KB
90 */
91 int getMemory();
92
93 }
94