/** * Cleans the mapping structure of any obsolete entries. This is usually * called before insertions and lookups on the mapping structure. The * runtime of this is usually very small, but it can be as expensive as * n * log(n) if a large number of soft references were recently cleared. */ private final void removeClearedEntries() { for ( Reference r = clearQueue.poll(); r != null; r = clearQueue.poll() ) { Object key = ( ( Entry ) r ).getKey(); map.remove( key ); } }
value = entry.getValue();
return null; value = entry.getValue(); if (value == null) { // object was in cache, but it was cleared. return null;
value = entry.getValue();
/** * Adds the specified value to the cache under the specified key. Note * that the object is added to both this and the internal cache. * @param key the (non-null) key to store the object under * @param value the (non-null) object to place in the cache * @throws CacheEvictionException exception that the internal cache * would have experienced while evicting an object it currently * cached. */ public void put( Object key, Object value ) throws CacheEvictionException { if ( key == null ) { throw new IllegalArgumentException( I18n.err( I18n.ERR_532 ) ); } else if ( value == null ) { throw new IllegalArgumentException( I18n.err( I18n.ERR_533 ) ); } internal.put( key, value ); removeClearedEntries(); map.put( key, new Entry( key, value, clearQueue ) ); }
/** * Adds the specified value to the cache under the specified key. Note * that the object is added to both this and the internal cache. * @param key the (non-null) key to store the object under * @param value the (non-null) object to place in the cache * @throws CacheEvictionException exception that the internal cache * would have experienced while evicting an object it currently * cached. */ public void put( Object key, Object value ) throws CacheEvictionException { if ( key == null ) { throw new IllegalArgumentException( I18n.err( I18n.ERR_532 ) ); } else if ( value == null ) { throw new IllegalArgumentException( I18n.err( I18n.ERR_533 ) ); } internal.put( key, value ); removeClearedEntries(); map.put( key, new Entry( key, value, clearQueue ) ); }
/** * Adds the specified value to the cache under the specified key. Note * that the object is added to both this and the internal cache. * @param key the (non-null) key to store the object under * @param value the (non-null) object to place in the cache * @throws CacheEvictionException exception that the internal cache * would have experienced while evicting an object it currently * cached. */ public void put(Object key, Object value) throws CacheEvictionException { if (key == null) { throw new IllegalArgumentException( I18n.err( I18n.ERR_532 ) ); } else if (value == null) { throw new IllegalArgumentException( I18n.err( I18n.ERR_533 ) ); } _internal.put(key, value); removeClearedEntries(); _cacheMap.put(key, new Entry(key, value, _clearQueue)); }
/** * Gets the value * @return the value; null if it is no longer accessible */ final Object getValue() { return this.get(); } }
/** * Cleans the mapping structure of any obsolete entries. This is usually * called before insertions and lookups on the mapping structure. The * runtime of this is usually very small, but it can be as expensive as * n * log(n) if a large number of soft references were recently cleared. */ private final void removeClearedEntries() { for ( Reference r = clearQueue.poll(); r != null; r = clearQueue.poll() ) { Object key = ( ( Entry ) r ).getKey(); map.remove( key ); } }
/** * Cleans the mapping structure of any obsolete entries. This is usually * called before insertions and lookups on the mapping structure. The * runtime of this is usually very small, but it can be as expensive as * n * log(n) if a large number of soft references were recently cleared. */ private final void removeClearedEntries() { for (Reference r = _clearQueue.poll(); r != null; r = _clearQueue.poll()) { Object key = ((Entry)r).getKey(); _cacheMap.remove(key); } }
/** * Gets the value * @return the value; null if it is no longer accessible */ final Object getValue() { return this.get(); } }
/** * Gets the value * @return the value; null if it is no longer accessible */ final Object getValue() { return this.get(); } }