List of usage examples for org.apache.commons.collections.map LRUMap LRUMap
public LRUMap(Map map)
From source file:de.hybris.platform.test.LRUMapTest.java
@Override protected Map createMapInstance() { return new LRUMap(100); }
From source file:de.hybris.platform.test.LRUMapTest.java
@Test public void testBug() { final LRUMap map = new LRUMap(2); map.put("1", "eins"); map.put("2", "zwei"); assertEquals("eins", map.get("1")); assertEquals("zwei", map.get("2")); map.put("3", "drei"); assertEquals(null, map.get("1")); assertEquals("zwei", map.get("2")); assertEquals("drei", map.get("3")); map.get("2"); map.put("4", "vier"); assertEquals(null, map.get("1")); assertEquals("zwei", map.get("2")); assertEquals(null, map.get("3")); assertEquals("vier", map.get("4")); }
From source file:net.big_oh.common.utils.RegExpHelper.java
@SuppressWarnings("unchecked") private static Map<String, Pattern> buildCompiledPatternsMap() { // The compiledPatterns Map is synchronized because it will be accessed // concurrently by multiple threads return Collections.synchronizedMap(new LRUMap(1000)); }
From source file:eu.annocultor.tagger.terms.ParentTermReconstructor.java
public ParentTermReconstructor(int maxCacheSize) { cache = new LRUMap(maxCacheSize); }
From source file:com.discursive.jccook.collections.cache.LRUCacheExample.java
private void start() { cache = new LRUMap(5); // Populate the cache with 5 stock prices cache.put("MSFT", new Float(0.03)); cache.put("TSC", new Float(0.001)); cache.put("LU", new Float(23.30)); cache.put("CSCO", new Float(242.20)); cache.put("P", new Float(10.23)); // Now use some of the entries in the cache Float cscoPrice = (Float) cache.get("CSCO"); Float msPrice = (Float) cache.get("MSFT"); Float tscPrice = (Float) cache.get("TSC"); Float luPrice = (Float) cache.get("LU"); Float pPrice = (Float) cache.get("P"); Float msPrice2 = (Float) cache.get("MSFT"); // Add another price to the Map, this should kick out the LRU item. cache.put("AA", new Float(203.20)); // CSCO was the first price requested, it is therefor the // least recently used. if (!cache.containsKey("CSCO")) { System.out.println("As expected CSCO was discarded"); }//from www. j a v a 2 s . co m }
From source file:com.mirth.connect.connectors.jms.DefaultRedeliveryHandler.java
public DefaultRedeliveryHandler() { messages = Collections.synchronizedMap(new LRUMap(256)); }
From source file:com.sitewhere.common.ExpiringLRUCache.java
@SuppressWarnings("unchecked") public ExpiringLRUCache(int size, int expirationInMs) { map = Collections.synchronizedMap(new LRUMap(size)); this.expirationInMS = expirationInMs; }
From source file:com.googlecode.tapestry5cayenne.services.DefaultNonPersistedObjectStorer.java
@SuppressWarnings("unchecked") public DefaultNonPersistedObjectStorer(@Symbol(TapestryCayenneCoreModule.UNPERSISTED_OBJECT_LIMIT) int limit) { _objs = new LRUMap(limit); }
From source file:com.vmware.identity.sts.impl.LRURequests.java
@SuppressWarnings("unchecked") LRURequests(int capacity) { assert capacity > 0; requests = new LRUMap(capacity); }
From source file:ch.cyberduck.ui.cocoa.AttributeCache.java
public AttributeCache(int size) { impl = Collections.<K, Map<String, NSObject>>synchronizedMap(new LRUMap(size) { @Override/*from ww w . j ava 2 s . c om*/ protected boolean removeLRU(LinkEntry entry) { log.debug("Removing from cache:" + entry); return true; } }); }