MCPcopy Create free account
hub / github.com/codenameone/CodenameOne / get

Method get

CodenameOne/src/com/codename1/io/CacheMap.java:161–192  ·  view source on GitHub ↗
(Object key)

Source from the content-addressed store, hash-verified

159 ///
160 /// value from a previous put or null
161 public Object get(Object key) {
162 Object[] o = (Object[]) memoryCache.get(key);
163 if (o != null) {
164 return o[1];
165 }
166 Object ref = weakCache.get(key);
167 if (ref != null) {
168 ref = Display.getInstance().extractHardRef(ref);
169 if (ref != null) {
170 // cache hit! Promote it to the hard cache again
171 put(key, ref);
172 return ref;
173 }
174 }
175 if (storageCacheSize > 0) {
176 Vector storageCacheContent = getStorageCacheContent();
177 for (int iter = 0; iter < storageCacheContent.size(); iter++) {
178 Object[] obj = (Object[]) storageCacheContent.elementAt(iter);
179 if (obj[1].equals(key)) {
180 // place the object back into the memory cache and return the value
181 Vector v = (Vector) Storage.getInstance().readObject("$CACHE$" + cachePrefix + key);
182 if (v != null) {
183 Object val = v.elementAt(0);
184 put(key, val);
185 return val;
186 }
187 return null;
188 }
189 }
190 }
191 return null;
192 }
193
194 /// Clears the caches for this cache object
195 public void clearAllCache() {

Callers 13

putAndGetMethod · 0.95
putMultipleItemsMethod · 0.95
getNonExistentKeyMethod · 0.95
deleteMethod · 0.95
clearMemoryCacheMethod · 0.95
clearAllCacheMethod · 0.95
putWithStorageCacheMethod · 0.95
updateExistingKeyMethod · 0.95

Calls 10

getInstanceMethod · 0.95
putMethod · 0.95
sizeMethod · 0.95
elementAtMethod · 0.95
getInstanceMethod · 0.95
getMethod · 0.65
equalsMethod · 0.65
extractHardRefMethod · 0.45
readObjectMethod · 0.45

Tested by 13

putAndGetMethod · 0.76
putMultipleItemsMethod · 0.76
getNonExistentKeyMethod · 0.76
deleteMethod · 0.76
clearMemoryCacheMethod · 0.76
clearAllCacheMethod · 0.76
putWithStorageCacheMethod · 0.76
updateExistingKeyMethod · 0.76