Project

General

Profile

Revision c4f09aa4

IDc4f09aa458b28c6d15a217ac6631f95c0fad4301
Parent d3986826
Child c1a5cfd5

Added by Andreas Müller about 5 years ago

Cleanup CdmTermCacher and CdmCacher

View differences:

cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/cache/CdmCacher.java
2 2

  
3 3
import java.util.UUID;
4 4

  
5
import eu.etaxonomy.cdm.model.ICdmUuidCacher;
6
import eu.etaxonomy.cdm.model.common.CdmBase;
5 7
import net.sf.ehcache.Cache;
6 8
import net.sf.ehcache.CacheManager;
7 9
import net.sf.ehcache.Element;
8 10
import net.sf.ehcache.config.CacheConfiguration;
9 11
import net.sf.ehcache.config.CacheConfiguration.CacheEventListenerFactoryConfiguration;
10 12
import net.sf.ehcache.store.MemoryStoreEvictionPolicy;
11
import eu.etaxonomy.cdm.model.ICdmUuidCacher;
12
import eu.etaxonomy.cdm.model.common.CdmBase;
13 13

  
14 14
/**
15 15
 * CDM Entity Cacher class based on EhCache.
......
65 65
        // For a better understanding on how to size caches, refer to
66 66
        // http://ehcache.org/documentation/configuration/cache-size
67 67
        return new CacheConfiguration(DEFAULT_CACHE_NAME, 500)
68
        .memoryStoreEvictionPolicy(MemoryStoreEvictionPolicy.LFU)
69
        .eternal(false)
70
        // default ttl and tti set to 2 hours
71
        .timeToLiveSeconds(60*60*2)
72
        .timeToIdleSeconds(60*60*2)
73
        .statistics(true);
68
                .memoryStoreEvictionPolicy(MemoryStoreEvictionPolicy.LFU)
69
                .eternal(false)
70
                // default ttl and tti set to 2 hours
71
                .timeToLiveSeconds(60*60*2)
72
                .timeToIdleSeconds(60*60*2)
73
                .statistics(true);
74 74

  
75 75
    }
76 76

  
......
102 102
        return getDefaultCache().get(uuid);
103 103
    }
104 104

  
105
    /* (non-Javadoc)
106
     * @see eu.etaxonomy.cdm.model.ICdmCacher#put(java.util.UUID, eu.etaxonomy.cdm.model.common.CdmBase)
107
     */
108 105
    @Override
109 106
    public  void put(UUID uuid, CdmBase cdmEntity) {
110 107
        CdmBase cachedCdmEntity = getFromCache(uuid);
......
113 110
        }
114 111
    }
115 112

  
116

  
117

  
118
    /* (non-Javadoc)
119
     * @see eu.etaxonomy.cdm.remote.cache.ICdmCacher#load(java.util.UUID)
120
     */
121 113
    @Override
122 114
    public CdmBase load(UUID uuid) {
123 115
        Element e = getCacheElement(uuid);
......
141 133
    }
142 134

  
143 135

  
144
    /* (non-Javadoc)
145
     * @see eu.etaxonomy.cdm.model.ICdmCacher#getFromCache(java.util.UUID)
146
     */
147 136
    @Override
148 137
    public  CdmBase getFromCache(UUID uuid) {
149 138
        Element e = getCacheElement(uuid);
......
154 143
        }
155 144
    }
156 145

  
157

  
158
    /* (non-Javadoc)
159
     * @see eu.etaxonomy.cdm.model.ICdmCacher#getFromCache(eu.etaxonomy.cdm.model.common.CdmBase)
160
     */
161 146
    @Override
162 147
    public CdmBase getFromCache(CdmBase cdmBase) {
163 148
        return getFromCache(cdmBase.getUuid());
164 149
    }
165 150

  
166 151

  
167

  
168
    /* (non-Javadoc)
169
     * @see eu.etaxonomy.cdm.model.ICdmCacher#put(eu.etaxonomy.cdm.model.common.CdmBase)
170
     */
171 152
    @Override
172 153
    public void put(CdmBase cdmEntity) {
173 154
        if(cdmEntity != null) {
......
175 156
        }
176 157
    }
177 158

  
178
    /* (non-Javadoc)
179
     * @see eu.etaxonomy.cdm.model.ICdmCacher#load(eu.etaxonomy.cdm.model.common.CdmBase)
180
     */
181 159
    @Override
182 160
    public abstract CdmBase load(CdmBase cdmEntity);
183 161

  
184 162

  
185

  
186

  
187
    /* (non-Javadoc)
188
     * @see eu.etaxonomy.cdm.model.ICdmCacher#exists(java.util.UUID)
189
     */
190 163
    @Override
191 164
    public boolean exists(UUID uuid) {
192 165
        return getCacheElement(uuid) != null;
193 166
    }
194 167

  
195

  
196
    /* (non-Javadoc)
197
     * @see eu.etaxonomy.cdm.model.ICdmCacher#exists(eu.etaxonomy.cdm.model.common.CdmBase)
198
     */
199 168
    @Override
200 169
    public boolean exists(CdmBase cdmBase) {
201 170
        if(cdmBase != null) {
......
205 174

  
206 175
    }
207 176

  
208
    /* (non-Javadoc)
209
     * @see eu.etaxonomy.cdm.model.ICdmCacher#existsAndIsNotNull(java.util.UUID)
210
     */
211 177
    @Override
212 178
    public boolean existsAndIsNotNull(UUID uuid) {
213 179
        Element e = getCacheElement(uuid);
......
226 192
     */
227 193
    protected abstract CdmBase findByUuid(UUID uuid);
228 194

  
229

  
230

  
231 195
}
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/cache/CdmTermCacher.java
27 27
        DefinedTermBase.setCacher(this);
28 28
	}
29 29

  
30
	/* (non-Javadoc)
31
	 * @see eu.etaxonomy.cdm.api.cache.CdmCacher#findByUuid(java.util.UUID)
32
	 */
33 30
	@Override
34 31
	protected  CdmBase findByUuid(UUID uuid) {
35 32
		return termService.findWithoutFlush(uuid);
36 33
	}
37 34

  
38 35

  
39

  
40
    /* (non-Javadoc)
41
     * @see eu.etaxonomy.cdm.model.ICdmCacher#isCachable(eu.etaxonomy.cdm.model.common.CdmBase)
42
     */
43 36
    @Override
44 37
    public boolean isCachable(CdmBase cdmEntity) {
45 38
        if(cdmEntity != null && cdmEntity instanceof DefinedTermBase) {
......
48 41
        return false;
49 42
    }
50 43

  
51
    /* (non-Javadoc)
52
     * @see eu.etaxonomy.cdm.api.cache.CdmCacher#load(eu.etaxonomy.cdm.model.common.CdmBase)
53
     */
54 44
    @Override
55 45
    public CdmBase load(CdmBase cdmEntity) {
56 46

  
......
62 52
        return cachedCdmEntity;
63 53

  
64 54
    }
65

  
66

  
67

  
68

  
69

  
70 55
}

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)