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)
| 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 |
nothing calls this directly
no test coverage detected