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

com.ajaxjs.util.cache.MemoryCacheManager Maven / Gradle / Ivy

There is a newer version: 1.2.6
Show newest version
package com.ajaxjs.util.cache;

import java.util.concurrent.ConcurrentHashMap;

/**
 * 基于虚拟机内存的cache管理器
 * 
 */
public class MemoryCacheManager extends ConcurrentHashMap> implements CacheManager {
	private static final long serialVersionUID = -8273827743219735439L;

	@Override
	public  Cache getCache(String name) {
		@SuppressWarnings("unchecked")
		Cache cache = (Cache) get(name);

		if (cache == null) {
			cache = new MemoryCache<>();
			put(name, cache);
		}

		return cache;
	}

	@Override
	public void destroy() {
		while (!isEmpty())
			clear();
	}

	@Override
	public  Cache getCache(String name, Class clz) {
		@SuppressWarnings("unchecked")
		Cache cache = (Cache) get(name);
		if (cache == null) {
			cache = new MemoryCache<>();
			put(name, cache);
		}

		return cache;
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy