1 | /* |
2 | |
3 | Derby - Class org.apache.derby.impl.services.cache.ClockFactory |
4 | |
5 | Copyright 1997, 2004 The Apache Software Foundation or its licensors, as applicable. |
6 | |
7 | Licensed under the Apache License, Version 2.0 (the "License"); |
8 | you may not use this file except in compliance with the License. |
9 | You may obtain a copy of the License at |
10 | |
11 | http://www.apache.org/licenses/LICENSE-2.0 |
12 | |
13 | Unless required by applicable law or agreed to in writing, software |
14 | distributed under the License is distributed on an "AS IS" BASIS, |
15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
16 | See the License for the specific language governing permissions and |
17 | limitations under the License. |
18 | |
19 | */ |
20 | |
21 | package org.apache.derby.impl.services.cache; |
22 | |
23 | import org.apache.derby.iapi.services.cache.CacheFactory; |
24 | import org.apache.derby.iapi.services.cache.CacheManager; |
25 | import org.apache.derby.iapi.services.cache.Cacheable; |
26 | import org.apache.derby.iapi.services.cache.CacheableFactory; |
27 | |
28 | import org.apache.derby.iapi.error.StandardException; |
29 | |
30 | import org.apache.derby.iapi.services.sanity.SanityManager; |
31 | |
32 | import java.util.Properties; |
33 | |
34 | /** |
35 | Multithreading considerations: no need to be MT-safe, caller (module control) |
36 | provides synchronization. Besides, this class is stateless. |
37 | */ |
38 | |
39 | public class ClockFactory implements CacheFactory { |
40 | |
41 | /** |
42 | Trace flag to display cache statistics |
43 | */ |
44 | public static final String CacheTrace = SanityManager.DEBUG ? "CacheTrace" : null; |
45 | |
46 | public ClockFactory() { |
47 | } |
48 | |
49 | |
50 | |
51 | /* |
52 | ** Methods of CacheFactory |
53 | */ |
54 | |
55 | public CacheManager newCacheManager(CacheableFactory holderFactory, String name, int initialSize, int maximumSize) |
56 | { |
57 | |
58 | if (initialSize <= 0) |
59 | initialSize = 1; |
60 | |
61 | return new Clock(holderFactory, name, initialSize, maximumSize, false); |
62 | } |
63 | |
64 | public CacheManager newSizedCacheManager(CacheableFactory holderFactory, String name, |
65 | int initialSize, long maximumSize) |
66 | { |
67 | |
68 | if (initialSize <= 0) |
69 | initialSize = 1; |
70 | |
71 | return new Clock(holderFactory, name, initialSize, maximumSize, true); |
72 | } |
73 | } |