X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=rapp-manager-models%2Fsrc%2Fmain%2Fjava%2Fcom%2Foransc%2Frappmanager%2Fmodels%2Fcache%2FRappCacheService.java;h=cdc42c696bf652eed43a56667ba0c968c2fa60c4;hb=HEAD;hp=ea34ae3193e10248e053516a23fa60494726d943;hpb=cc47a6f5ed71a062df5fa94aadc5d1eb87cd3258;p=nonrtric%2Fplt%2Frappmanager.git diff --git a/rapp-manager-models/src/main/java/com/oransc/rappmanager/models/cache/RappCacheService.java b/rapp-manager-models/src/main/java/com/oransc/rappmanager/models/cache/RappCacheService.java deleted file mode 100755 index ea34ae3..0000000 --- a/rapp-manager-models/src/main/java/com/oransc/rappmanager/models/cache/RappCacheService.java +++ /dev/null @@ -1,65 +0,0 @@ -/*- - * ============LICENSE_START====================================================================== - * Copyright (C) 2023 Nordix Foundation. All rights reserved. - * =============================================================================================== - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END======================================================================== - */ - -package com.oransc.rappmanager.models.cache; - -import com.oransc.rappmanager.models.rapp.Rapp; -import java.util.Collection; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import lombok.RequiredArgsConstructor; -import org.springframework.cache.Cache; -import org.springframework.cache.CacheManager; -import org.springframework.stereotype.Service; - -@Service -@RequiredArgsConstructor -public class RappCacheService { - - private final String RAPP_CACHE = "rapp-cache"; - private final CacheManager cacheManager; - - public Collection getAllRapp() { - Cache cache = cacheManager.getCache(RAPP_CACHE); - if (cache != null) { - Map nativeCache = (Map) cache.getNativeCache(); - return nativeCache.values(); - } - return List.of(); - } - - public Optional getRapp(String rappId) { - final Cache cache = cacheManager.getCache(RAPP_CACHE); - return Optional.ofNullable(cache.get(rappId, Rapp.class)); - } - - public void putRapp(Rapp rapp) { - final Cache cache = cacheManager.getCache(RAPP_CACHE); - if (cache != null) { - cache.put(rapp.getName(), rapp); - } - } - - public void deleteRapp(Rapp rapp) { - final Cache cache = cacheManager.getCache(RAPP_CACHE); - if (cache != null) { - cache.evict(rapp.getName()); - } - } -}