Imported vpnservice as a subtree
[netvirt.git] / vpnservice / mdsalutil / mdsalutil-api / src / main / java / org / opendaylight / vpnservice / utils / cache / CacheUtil.java
1 /*
2  * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.vpnservice.utils.cache;
9
10 import java.util.concurrent.ConcurrentHashMap;
11 import java.util.concurrent.ConcurrentMap;
12
13 public class CacheUtil {
14     private static final ConcurrentMap<String, ConcurrentMap<?, ?>> m_mapCache = 
15             new ConcurrentHashMap<String, ConcurrentMap<?, ?>>();
16
17     public static ConcurrentMap<?, ?> getCache(String sCacheName) {
18         return m_mapCache.get(sCacheName);
19     }
20
21     public static void createCache(String sCacheName) {
22         if (m_mapCache.get(sCacheName) == null)
23             m_mapCache.put(sCacheName, new ConcurrentHashMap<Object, Object>());
24     }
25
26     public static void destroyCache(String sCacheName) {
27         m_mapCache.remove(sCacheName);
28     }
29 }