All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.librato.metrics.reporter.LRU Maven / Gradle / Ivy

Go to download

The LibratoReporter class runs in the background, publishing metrics to the Librato Metrics API at the specified interval.

The newest version!
package com.librato.metrics.reporter;

import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.Map;

public class LRU {
    private final Map cache;

    public LRU(final int maxSize) {
        this.cache = Collections.synchronizedMap(new LinkedHashMap() {
            @Override
            protected boolean removeEldestEntry(Map.Entry eldest) {
                return size() > maxSize;
            }
        });
    }

    public V get(K key) {
        return cache.get(key);
    }

    public void set(K key, V result) {
        cache.put(key, result);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy