@Test public void testPut() throws Exception { ConcurrentFIFOExoCache<String, String> cache = new ConcurrentFIFOExoCache<>(LIMIT); CountDownLatch start = new CountDownLatch(1); CountDownLatch finish = new CountDownLatch(1000); for (int i = 0; i < 1000; i++) { Thread t = new Thread(new Runnable() { @Override public void run() { try { start.await(10, TimeUnit.SECONDS); } catch (InterruptedException e) { Assert.fail("CountDownLatch fail to wait"); } for (int j = 0; j < 10000; j++) { if (cache.getCacheSize() <= LIMIT) { cache.put("", ""); } } finish.countDown(); } }); t.start(); } start.countDown(); finish.await(1, TimeUnit.MINUTES); Assert.assertEquals(LIMIT, cache.getCacheSize()); }
public void put(K name, V obj) { if (name == null) { throw new IllegalArgumentException("No null cache key accepted"); } if (liveTimeMillis != 0) { long expirationTime = liveTimeMillis > 0 ? System.currentTimeMillis() + liveTimeMillis : Long.MAX_VALUE; state.put(expirationTime, name, obj, false); } }
ConcurrentFIFOExoCache implements ExoCache<K, V> { public void put(K name, V obj) { if (name == null) { throw new IllegalArgumentException("No null cache key accepted"); } if (liveTimeMillis != 0) { long expirationTime = liveTimeMillis > 0 ? System.currentTimeMillis() + liveTimeMillis : Long.MAX_VALUE; state.put(expirationTime, name, obj, false); } } }
ConcurrentFIFOExoCache implements ExoCache<K, V> { public void put(K name, V obj) { if (name == null) { throw new IllegalArgumentException("No null cache key accepted"); } if (liveTimeMillis != 0) { long expirationTime = liveTimeMillis > 0 ? System.currentTimeMillis() + liveTimeMillis : Long.MAX_VALUE; state.put(expirationTime, name, obj, false); } } ConcurrentFIFOExoCache();  ConcurrentFIFOExoCache(Log log);  ConcurrentFIFOExoCache(int maxSize);  ConcurrentFIFOExoCache(int maxSize, Log log);  ConcurrentFIFOExoCache(String name, int maxSize);  ConcurrentFIFOExoCache(String name, int maxSize, Log log); }
ConcurrentFIFOExoCache implements ExoCache<K, V> { public void put(K name, V obj) { if (name == null) { throw new IllegalArgumentException("No null cache key accepted"); } if (liveTimeMillis != 0) { long expirationTime = liveTimeMillis > 0 ? System.currentTimeMillis() + liveTimeMillis : Long.MAX_VALUE; state.put(expirationTime, name, obj, false); } } ConcurrentFIFOExoCache();  ConcurrentFIFOExoCache(Log log);  ConcurrentFIFOExoCache(int maxSize);  ConcurrentFIFOExoCache(int maxSize, Log log);  ConcurrentFIFOExoCache(String name, int maxSize);  ConcurrentFIFOExoCache(String name, int maxSize, Log log); void assertConsistent(); String getName(); void setName(String s); String getLabel(); void setLabel(String name); long getLiveTime(); void setLiveTime(long period); long getLiveTimeMillis(); void setLiveTimeMillis(long liveTimeMillis); int getMaxSize(); void setMaxSize(int max); V get(Serializable name); void put(K name, V obj); void putLocal(K name, V obj); void putMap(Map<? extends K, ? extends V> objs); V remove(Serializable name); List<? extends V> getCachedObjects(); List<? extends V> removeCachedObjects(); void clearCache(); void select(CachedObjectSelector<? super K, ? super V> selector); int getCacheSize(); int getCacheHit(); int getCacheMiss(); synchronized void addCacheListener(CacheListener<? super K, ? super V> listener); boolean isLogEnabled(); void setLogEnabled(boolean logEnabled); void onExpire(K key, V obj); void onRemove(K key, V obj); void onPut(K key, V obj); void onPutLocal(K key, V obj); void onGet(K key, V obj); void onClearCache(); List<ListenerContext<K, V>> getListeners(); }
ConcurrentFIFOExoCache implements ExoCache<K, V> { public void put(K name, V obj) { if (name == null) { throw new IllegalArgumentException("No null cache key accepted"); } if (liveTimeMillis != 0) { long expirationTime = liveTimeMillis > 0 ? System.currentTimeMillis() + liveTimeMillis : Long.MAX_VALUE; state.put(expirationTime, name, obj, false); } } ConcurrentFIFOExoCache();  ConcurrentFIFOExoCache(Log log);  ConcurrentFIFOExoCache(int maxSize);  ConcurrentFIFOExoCache(int maxSize, Log log);  ConcurrentFIFOExoCache(String name, int maxSize);  ConcurrentFIFOExoCache(String name, int maxSize, Log log); void assertConsistent(); String getName(); void setName(String s); String getLabel(); void setLabel(String name); long getLiveTime(); void setLiveTime(long period); long getLiveTimeMillis(); void setLiveTimeMillis(long liveTimeMillis); int getMaxSize(); void setMaxSize(int max); V get(Serializable name); void put(K name, V obj); void putLocal(K name, V obj); void putMap(Map<? extends K, ? extends V> objs); V remove(Serializable name); List<? extends V> getCachedObjects(); List<? extends V> removeCachedObjects(); void clearCache(); void select(CachedObjectSelector<? super K, ? super V> selector); int getCacheSize(); int getCacheHit(); int getCacheMiss(); synchronized void addCacheListener(CacheListener<? super K, ? super V> listener); boolean isLogEnabled(); void setLogEnabled(boolean logEnabled); void onExpire(K key, V obj); void onRemove(K key, V obj); void onPut(K key, V obj); void onPutLocal(K key, V obj); void onGet(K key, V obj); void onClearCache(); List<ListenerContext<K, V>> getListeners();  }