001package ca.uhn.fhir.sl.cache.caffeine;
002
003/*-
004 * #%L
005 * HAPI FHIR - ServiceLoaders - Caching Caffeine
006 * %%
007 * Copyright (C) 2014 - 2023 Smile CDR, Inc.
008 * %%
009 * Licensed under the Apache License, Version 2.0 (the "License");
010 * you may not use this file except in compliance with the License.
011 * You may obtain a copy of the License at
012 *
013 *      http://www.apache.org/licenses/LICENSE-2.0
014 *
015 * Unless required by applicable law or agreed to in writing, software
016 * distributed under the License is distributed on an "AS IS" BASIS,
017 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
018 * See the License for the specific language governing permissions and
019 * limitations under the License.
020 * #L%
021 */
022
023import java.util.Map;
024import java.util.function.Function;
025
026public class CacheDelegator<K, V> implements ca.uhn.fhir.sl.cache.Cache<K, V> {
027
028        com.github.benmanes.caffeine.cache.Cache<K, V> cache;
029
030        public CacheDelegator(com.github.benmanes.caffeine.cache.Cache<K, V> impl) {
031                this.cache = impl;
032        }
033
034        @Override
035        public V getIfPresent(K key) {
036                return cache.getIfPresent(key);
037        }
038
039        @Override
040        public V get(K key, Function<? super K, ? extends V> mappingFunction) {
041                return cache.get(key, mappingFunction);
042        }
043
044        @Override
045        public Map<K, V> getAllPresent(Iterable<? extends K> keys) { return cache.getAllPresent(keys); }
046
047        @Override
048        public void put(K key, V value) {
049                cache.put(key, value);
050        }
051
052        @Override
053        public void putAll(Map<? extends K, ? extends V> map) {
054                cache.putAll(map);
055        }
056
057        @Override
058        public void invalidate(K key) { cache.invalidate(key); }
059
060        @Override
061        public void invalidateAll(Iterable<? extends K> keys)  {
062                cache.invalidateAll(keys);
063        }
064
065        @Override
066        public void invalidateAll() {
067                cache.invalidateAll();
068        }
069
070        @Override
071        public long estimatedSize() {
072                return cache.estimatedSize();
073        }
074
075        @Override
076        public void cleanUp(){
077                cache.cleanUp();
078        }
079}