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

org.nutz.web.cache.EasyCacheManager Maven / Gradle / Ivy

Go to download

Nutz, which is a collections of lightweight frameworks, each of them can be used independently

There is a newer version: 1.r.67
Show newest version
package org.nutz.web.cache;

import java.util.HashMap;
import java.util.Map;

public abstract class EasyCacheManager implements CacheManager {

    private Map cache = new HashMap();

    private T _new(String key) {
        T value = null;
        value = create(key);
        if (value != null) {
            cache.put(key, value);
        }
        return value;
    }

    public synchronized T get(String key) {
        T value = null;
        if (cache.containsKey(key)) {
            value = cache.get(key);
            if (isExpired(value)) {
                value = _new(key);
            }
        } else {
            value = _new(key);
        }
        return value;
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy