org.babyfish.jimmer.sql.cache.spi.AbstractRemoteValueBinder 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.spi;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.babyfish.jimmer.meta.ImmutableProp;
import org.babyfish.jimmer.meta.ImmutableType;
import org.babyfish.jimmer.sql.cache.CacheTracker;
import org.jetbrains.annotations.Nullable;
import java.time.Duration;
import java.util.Collection;
import java.util.List;
import java.util.Map;
public abstract class AbstractRemoteValueBinder
extends AbstractRemoteBinder {
protected AbstractRemoteValueBinder(
@Nullable ImmutableType type,
@Nullable ImmutableProp prop,
@Nullable CacheTracker tracker,
@Nullable ObjectMapper objectMapper,
Duration duration,
int randomPercent
) {
super(type, prop, tracker, objectMapper, duration, randomPercent);
}
@Override
public final Map getAll(Collection keys) {
Collection redisKeys = serializedKeys(keys);
List values = read(redisKeys);
return valueSerializer.deserialize(keys, values);
}
@Override
public final void setAll(Map map) {
Map convertedMap = valueSerializer.serialize(map, this::serializedKey);
write(convertedMap);
}
protected abstract List read(Collection keys);
protected abstract void write(Map map);
}