/** * Add an object to the cache * * @param cacheModel The cacheModel * @param key The key of the object to be cached * @param value The object to be cached */ public void putObject(CacheModel cacheModel, Object key, Object value) { Object reference = null; if (referenceType.equals(MemoryCacheLevel.WEAK)) { reference = new WeakReference(value); } else if (referenceType.equals(MemoryCacheLevel.SOFT)) { reference = new SoftReference(value); } else if (referenceType.equals(MemoryCacheLevel.STRONG)) { reference = new StrongReference(value); } cache.put(key, reference); }
/** * Configures the cache * * @param props Optionally can contain properties [reference-type=WEAK|SOFT|STRONG] */ public void setProperties(Properties props) { String refType = props.getProperty("reference-type"); if (refType == null) { refType = props.getProperty("referenceType"); } if (refType != null) { referenceType = MemoryCacheLevel.getByReferenceType(refType); } }