Puts or loads the passed element into the cache @param key The key for the element, used to reference it in the hastables and LRU linked list @param value The value of the element
(Object key, Object value)
| 162 | * The value of the element |
| 163 | */ |
| 164 | public void put(Object key, Object value) { |
| 165 | if ((key == null) || (value == null)) |
| 166 | return; |
| 167 | |
| 168 | try { |
| 169 | if (maxSize > 0) { |
| 170 | // when maxSize is changed, the setter will take care of filling |
| 171 | // the |
| 172 | // LRU list |
| 173 | if (cacheLineTable.containsKey(key)) { |
| 174 | keyLRUList.moveFirst(key); |
| 175 | } else { |
| 176 | keyLRUList.addFirst(key); |
| 177 | } |
| 178 | } |
| 179 | |
| 180 | if (expireTime > 0) { |
| 181 | cacheLineTable.put(key, new CacheLine(value, useSoftReference, System.currentTimeMillis())); |
| 182 | } else { |
| 183 | cacheLineTable.put(key, new CacheLine(value, useSoftReference)); |
| 184 | } |
| 185 | if (maxSize > 0 && cacheLineTable.size() > maxSize) { |
| 186 | Object lastKey = keyLRUList.getLast(); |
| 187 | removeObject(lastKey); |
| 188 | } |
| 189 | } catch (Exception e) { |
| 190 | Debug.logError(e); |
| 191 | } finally { |
| 192 | } |
| 193 | Debug.logVerbose("[JdonFramework]cache now size = " + keyLRUList.size() + " maxSize =" + maxSize + " this Cache id:" + this.hashCode(), |
| 194 | module); |
| 195 | } |
| 196 | |
| 197 | /** |
| 198 | * Gets an element from the cache according to the specified key. If the |
nothing calls this directly
no test coverage detected