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

com.github.ltsopensource.kv.cache.LRUDataCache Maven / Gradle / Ivy

package com.github.ltsopensource.kv.cache;

import com.github.ltsopensource.core.commons.utils.LRUCache;

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

/**
 * 用来缓存
 * @author Robert HG ([email protected]) on 12/18/15.
 */
public class LRUDataCache implements DataCache {

    private Map cache;

    public LRUDataCache(final int maxCacheSize) {
        this.cache = Collections.synchronizedMap(new LRUCache(maxCacheSize));
    }

    @Override
    public void put(K key, V value) {
        cache.put(key, value);
    }

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

    @Override
    public V remove(K key) {
        return cache.remove(key);
    }

    @Override
    public int size() {
        return cache.size();
    }

    @Override
    public void clear() {
        cache.clear();
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy