org.babyfish.jimmer.sql.cache.Cache Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jimmer-sql Show documentation
Show all versions of jimmer-sql Show documentation
A revolutionary ORM framework for both java and kotlin
package org.babyfish.jimmer.sql.cache;
import org.babyfish.jimmer.meta.ImmutableProp;
import org.babyfish.jimmer.meta.ImmutableType;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Collection;
import java.util.Collections;
import java.util.Map;
import java.util.SortedMap;
public interface Cache {
@NotNull
ImmutableType type();
@Nullable ImmutableProp prop();
@Nullable default V get(@NotNull K key, @NotNull CacheEnvironment env) {
return getAll(Collections.singleton(key), env).get(key);
}
@NotNull Map getAll(@NotNull Collection keys, @NotNull CacheEnvironment env);
default void delete(@NotNull K key) {
deleteAll(Collections.singleton(key), null);
}
default void delete(@NotNull K key, Object reason) {
deleteAll(Collections.singleton(key), reason);
}
default void deleteAll(@NotNull Collection keys) {
deleteAll(keys, null);
}
void deleteAll(@NotNull Collection keys, @Nullable Object reason);
interface Parameterized extends Cache {
@Nullable
default V get(
@NotNull K key,
@NotNull SortedMap parameterMap,
@NotNull CacheEnvironment env
) {
return getAll(Collections.singleton(key), parameterMap, env).get(key);
}
@NotNull
Map getAll(
@NotNull Collection keys,
@NotNull SortedMap parameterMap,
@NotNull CacheEnvironment env
);
}
}