1. 程式人生 > >java實現快取Map

java實現快取Map

package cn.com
import java.util.HashMap;
import java.util.Map;

import org.springframework.stereotype.Service;

@Service
public class CacheService {

	public static Map<String, String> sessionMap = new HashMap<String, String>();

	public static String getSessionMap(String key) {
		if(sessionMap.get(key) == null){
			return "first";
		}
		return sessionMap.get(key);
	}

	public static void setSessionMap(String key, String value) {
		sessionMap.put(key, value);
	}
	
}