MCPcopy Create free account
hub / github.com/banq/jdonframework / get

Method get

src/main/java/com/jdon/cache/UtilCache.java:207–234  ·  view source on GitHub ↗

Gets an element from the cache according to the specified key. If the requested element hasExpired, it is removed before it is looked up which causes the function to return null. @param key The key for the element, used to reference it in the hastables and LRU linked list @ret

(final Object key)

Source from the content-addressed store, hash-verified

205 * @return The value of the element specified by the key
206 */
207 public Object get(final Object key) {
208 if (key == null)
209 return null;
210 if (!cacheLineTable.containsKey(key))
211 return null;
212 CacheLine line = (CacheLine) cacheLineTable.get(key);
213
214 if (hasExpired(line)) {
215 removeObject(key);
216 line = null;
217 }
218
219 if (line == null) {
220 missCount++;
221 return null;
222 }
223
224 hitCount++;
225 // double hitPercent = 100*(double)hitCount/(hitCount + missCount);
226 // Debug.logVerbose("[JdonFramework]cache hit percent: " +
227 // percentFormat.format(hitPercent)+"%", module);
228
229 if (maxSize > 0) {
230 keyLRUList.moveFirst(key);
231 }
232
233 return line.getValue();
234 }
235
236 /**
237 * Removes an element from the cache according to the specified key

Callers

nothing calls this directly

Calls 6

hasExpiredMethod · 0.95
removeObjectMethod · 0.95
getValueMethod · 0.95
containsKeyMethod · 0.80
moveFirstMethod · 0.80
getMethod · 0.65

Tested by

no test coverage detected