1 package com.jdon.util; 2 3 import java.util.Map ; 4 import java.util.concurrent.ConcurrentHashMap ; 5 6 13 public class SimpleCachePool { 14 15 private static SimpleCachePool _instance; 16 private static int _SIZE = 100000; 17 18 private Map _scPool; 19 20 public static Object get(String id) { 21 return _getInstance()._get(id); 22 } 23 24 public static void put(String id, Object obj) { 25 _getInstance()._put(id, obj); 26 } 27 28 public static Object remove(String id) { 29 return _getInstance()._remove(id); 30 } 31 32 private static SimpleCachePool _getInstance() { 33 if (_instance == null) { 34 synchronized (SimpleCachePool.class) { 35 if (_instance == null) { 36 _instance = new SimpleCachePool(); 37 } 38 } 39 } 40 return _instance; 41 } 42 43 private SimpleCachePool() { 44 _scPool = new ConcurrentHashMap (_SIZE); 45 } 46 47 private Object _get(String id) { 48 return (Object )_scPool.get(id); 49 } 50 51 private void _put(String id, Object ds) { 52 _scPool.put(id, ds); 53 } 54 55 private Object _remove(String id) { 56 return _scPool.remove(id); 57 } 58 59 60 61 } 62 | Popular Tags |