2 * ============LICENSE_START===================================================
3 * SPARKY (AAI UI service)
4 * ============================================================================
5 * Copyright © 2017 AT&T Intellectual Property.
6 * Copyright © 2017 Amdocs
8 * ============================================================================
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
20 * ============LICENSE_END=====================================================
22 * ECOMP and OpenECOMP are trademarks
23 * and service marks of AT&T Intellectual Property.
26 package org.openecomp.sparky.dal.cache;
28 import java.util.concurrent.ConcurrentHashMap;
30 import org.openecomp.cl.api.Logger;
31 import org.openecomp.cl.eelf.LoggerFactory;
32 import org.openecomp.sparky.dal.rest.OperationResult;
33 import org.openecomp.sparky.logging.AaiUiMsgs;
36 * The Class InMemoryEntityCache.
40 public class InMemoryEntityCache implements EntityCache {
42 private ConcurrentHashMap<String, OperationResult> cachedEntityData;
43 private static final Logger LOG =
44 LoggerFactory.getInstance().getLogger(InMemoryEntityCache.class);
47 * Instantiates a new in memory entity cache.
49 public InMemoryEntityCache() {
50 cachedEntityData = new ConcurrentHashMap<String, OperationResult>();
54 * @see org.openecomp.sparky.dal.cache.EntityCache#put(java.lang.String, org.openecomp.sparky.dal.rest.OperationResult)
57 public void put(String key, OperationResult data) {
62 if (cachedEntityData.putIfAbsent(key, data) != null) {
63 if (LOG.isDebugEnabled()) {
64 LOG.debug(AaiUiMsgs.DATA_CACHE_SUCCESS, key);
71 * @see org.openecomp.sparky.dal.cache.EntityCache#get(java.lang.String, java.lang.String)
74 public OperationResult get(String entityKey, String link) {
77 return cachedEntityData.get(link);
84 * @see org.openecomp.sparky.dal.cache.EntityCache#shutdown()
87 public void shutdown() {
88 // TODO Auto-generated method stub
94 * @see org.openecomp.sparky.dal.cache.EntityCache#clear()
98 cachedEntityData.clear();