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

com.ly.mybatis.mapperservice.holder.ICacheHolder Maven / Gradle / Ivy

package com.ly.mybatis.mapperservice.holder;


@SuppressWarnings("unused")
public interface ICacheHolder {
    ConcurrentReferenceHashMap, ConcurrentReferenceHashMap> cache = new ConcurrentReferenceHashMap<>();

    default  T getCast(K key) {
        return (T) get(key);
    }

    default V get(K key) {
        getCache().purgeUnreferencedEntries();
        return getCache().computeIfAbsent(key, this::produce);
    }

    default ConcurrentReferenceHashMap getCache() {
        cache.purgeUnreferencedEntries();
        cache.putIfAbsent(getClass(), new ConcurrentReferenceHashMap());
        return (ConcurrentReferenceHashMap) cache.get(getClass());
    }

    V produce(K key);

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy