Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright 2017-2022 the original author or authors.
*
* 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
*
* https://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 org.springframework.data.redis.core;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import java.nio.ByteBuffer;
import java.time.Duration;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import org.reactivestreams.Publisher;
import org.springframework.data.redis.connection.BitFieldSubCommands;
import org.springframework.data.redis.connection.ReactiveStringCommands;
import org.springframework.data.redis.connection.RedisStringCommands.SetOption;
import org.springframework.data.redis.core.types.Expiration;
import org.springframework.data.redis.serializer.RedisSerializationContext;
import org.springframework.data.redis.serializer.RedisSerializationContext.SerializationPair;
import org.springframework.util.Assert;
/**
* Default implementation of {@link ReactiveValueOperations}.
*
* @author Mark Paluch
* @author Christoph Strobl
* @author Jiahe Cai
* @since 2.0
*/
class DefaultReactiveValueOperations implements ReactiveValueOperations {
private final ReactiveRedisTemplate template;
private final RedisSerializationContext serializationContext;
DefaultReactiveValueOperations(ReactiveRedisTemplate template,
RedisSerializationContext serializationContext) {
this.template = template;
this.serializationContext = serializationContext;
}
/* (non-Javadoc)
* @see org.springframework.data.redis.core.ReactiveValueOperations#set(java.lang.Object, java.lang.Object)
*/
@Override
public Mono set(K key, V value) {
Assert.notNull(key, "Key must not be null!");
return createMono(connection -> connection.set(rawKey(key), rawValue(value)));
}
/* (non-Javadoc)
* @see org.springframework.data.redis.core.ReactiveValueOperations#set(java.lang.Object, java.lang.Object, long, java.util.concurrent.TimeUnit)
*/
@Override
public Mono set(K key, V value, Duration timeout) {
Assert.notNull(key, "Key must not be null!");
Assert.notNull(timeout, "Duration must not be null!");
return createMono(
connection -> connection.set(rawKey(key), rawValue(value), Expiration.from(timeout), SetOption.UPSERT));
}
/* (non-Javadoc)
* @see org.springframework.data.redis.core.ReactiveValueOperations#setIfAbsent(java.lang.Object, java.lang.Object)
*/
@Override
public Mono setIfAbsent(K key, V value) {
Assert.notNull(key, "Key must not be null!");
return createMono(
connection -> connection.set(rawKey(key), rawValue(value), Expiration.persistent(), SetOption.SET_IF_ABSENT));
}
/* (non-Javadoc)
* @see org.springframework.data.redis.core.ReactiveValueOperations#setIfAbsent(java.lang.Object, java.lang.Object, java.time.Duration)
*/
@Override
public Mono setIfAbsent(K key, V value, Duration timeout) {
Assert.notNull(key, "Key must not be null!");
Assert.notNull(timeout, "Duration must not be null!");
return createMono(
connection -> connection.set(rawKey(key), rawValue(value), Expiration.from(timeout), SetOption.SET_IF_ABSENT));
}
/* (non-Javadoc)
* @see org.springframework.data.redis.core.ReactiveValueOperations#setIfPresent(java.lang.Object, java.lang.Object)
*/
@Override
public Mono setIfPresent(K key, V value) {
Assert.notNull(key, "Key must not be null!");
return createMono(
connection -> connection.set(rawKey(key), rawValue(value), Expiration.persistent(), SetOption.SET_IF_PRESENT));
}
/* (non-Javadoc)
* @see org.springframework.data.redis.core.ReactiveValueOperations#setIfPresent(java.lang.Object, java.lang.Object, java.time.Duration)
*/
@Override
public Mono setIfPresent(K key, V value, Duration timeout) {
Assert.notNull(key, "Key must not be null!");
Assert.notNull(timeout, "Duration must not be null!");
return createMono(
connection -> connection.set(rawKey(key), rawValue(value), Expiration.from(timeout), SetOption.SET_IF_PRESENT));
}
/* (non-Javadoc)
* @see org.springframework.data.redis.core.ReactiveValueOperations#multiSet(java.util.Map)
*/
@Override
public Mono multiSet(Map map) {
Assert.notNull(map, "Map must not be null!");
return createMono(connection -> {
Mono