001package ca.uhn.fhir.sl.cache.caffeine;
002
003/*-
004 * #%L
005 * HAPI FHIR - ServiceLoaders - Caching Caffeine
006 * %%
007 * Copyright (C) 2014 - 2024 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) {
046                return cache.getAllPresent(keys);
047        }
048
049        @Override
050        public void put(K key, V value) {
051                cache.put(key, value);
052        }
053
054        @Override
055        public void putAll(Map<? extends K, ? extends V> map) {
056                cache.putAll(map);
057        }
058
059        @Override
060        public void invalidate(K key) {
061                cache.invalidate(key);
062        }
063
064        @Override
065        public void invalidateAll(Iterable<? extends K> keys) {
066                cache.invalidateAll(keys);
067        }
068
069        @Override
070        public void invalidateAll() {
071                cache.invalidateAll();
072        }
073
074        @Override
075        public long estimatedSize() {
076                return cache.estimatedSize();
077        }
078
079        @Override
080        public void cleanUp() {
081                cache.cleanUp();
082        }
083}