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

com.github.yiuman.citrus.support.cache.MapCache Maven / Gradle / Ivy

package com.github.yiuman.citrus.support.cache;

import java.util.Collection;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @author yiuman
 * @date 2020/4/6
 */
public class MapCache implements Cache {

    private ConcurrentHashMap cache = new ConcurrentHashMap<>(256);

    public MapCache() {
    }

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

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

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

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

    @Override
    public boolean contains(K key) {
        return cache.containsKey(key);
    }

    @Override
    public Collection keys() {
        return cache.keySet();
    }

    @Override
    public Map map() {
        return this.cache;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy