@Override public void update(long value) { if (count.incrementAndGet() % REMOVE_IN_UPDATE_THRESHOLD == 0) { removeExpireValues(); } storage.put(getUpdatingTime(), value); }
@Override public void update(long value) { if (count.incrementAndGet() % REMOVE_IN_UPDATE_THRESHOLD == 0) { removeExpireValues(); } storage.put(getUpdatingTime(), value); }
/** * Remove the values that are earlier than current window */ private void removeExpireValues() { storage.headMap(getUpdatingTime() - windowMs).clear(); }
/** * Remove the values that are earlier than current window */ private void removeExpireValues() { storage.headMap(getUpdatingTime() - windowMs).clear(); }