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); } }
public void putMap(Map<? extends K, ? extends V> objs) { if (objs == null) { throw new IllegalArgumentException("No null map accepted"); } long expirationTime = liveTimeMillis > 0 ? System.currentTimeMillis() + liveTimeMillis : Long.MAX_VALUE; for (Serializable name : objs.keySet()) { if (name == null) { throw new IllegalArgumentException("No null cache key accepted"); } } for (Map.Entry<? extends K, ? extends V> entry : objs.entrySet()) { state.put(expirationTime, entry.getKey(), entry.getValue()); } }