View Javadoc
1   /**
2    * Copyright By Grandsoft Company Limited.  
3    * 2012-6-5 上午10:40:01
4    */
5   package gboat2.base.cache;
6   
7   
8   /**
9    * 
10   * 缓存对象管理器,使用缓存时借助此类,可以实现缓存的增加删除获得。
11   * 
12   * @author zhangxj-a
13   * @since 1.0
14   * @date 2012-6-5
15   */
16  public class CacheManager {
17  
18      private BaseCache cache = null;
19  
20      private static CacheManager instance;
21  
22      private static Object lock = new Object();
23  
24      /**
25       * 私有构造方法,防止在外部被实例化
26       */
27      private CacheManager() {
28          cache = new BaseCache();
29      }
30  
31      /**
32       * 获取单例对象
33       * @return
34       */
35      public static CacheManager getInstance() {
36          if (instance == null) {
37              synchronized (lock) {
38                  instance = new CacheManager();
39              }
40          }
41  
42          return instance;
43      }
44  
45      /**
46       * 获取cache方法,通过此方法可以缓存对象,删除对象操作
47       * 
48       * @return
49       */
50      public static BaseCache getCache() {
51          return getInstance().cache;
52      }
53  }