
io.fluxcapacitor.common.caching.Cache Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of common Show documentation
Show all versions of common Show documentation
Library with common components for Flux Capacitor clients and service.
/*
* Copyright (c) Flux Capacitor IP B.V. or its affiliates. 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.
*/
package io.fluxcapacitor.common.caching;
import io.fluxcapacitor.common.Registration;
import java.util.Optional;
import java.util.function.BiFunction;
import java.util.function.Consumer;
import java.util.function.Function;
public interface Cache {
Object put(Object id, Object value);
Object putIfAbsent(Object id, Object value);
T computeIfAbsent(Object id, Function super Object, T> mappingFunction);
T computeIfPresent(Object id, BiFunction super Object, ? super T, ? extends T> mappingFunction);
T compute(Object id, BiFunction super Object, ? super T, ? extends T> mappingFunction);
void modifyEach(BiFunction super Object, ? super T, ? extends T> modifierFunction);
T get(Object id);
default T getOrDefault(Object id, T defaultValue) {
return Optional.ofNullable(get(id)).orElse(defaultValue);
}
boolean containsKey(Object id);
T remove(Object id);
void clear();
int size();
default boolean isEmpty() {
return size() < 1;
}
Registration registerEvictionListener(Consumer listener);
void close();
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy