All Downloads are FREE. Search and download functionalities are using the official Maven repository.
Please wait. This can take some minutes ...
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.
org.springframework.data.redis.core.ReactiveValueOperationsExtensions.kt Maven / Gradle / Ivy
/*
* Copyright 2019 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 kotlinx.coroutines.reactive.awaitFirstOrNull
import kotlinx.coroutines.reactive.awaitSingle
import org.springframework.data.redis.connection.BitFieldSubCommands
import java.time.Duration
/**
* Coroutines variant of [ReactiveValueOperations.set].
*
* @author Mark Paluch
* @since 2.2
*/
suspend fun ReactiveValueOperations.setAndAwait(key: K, value: V): Boolean =
set(key, value).awaitSingle()
/**
* Coroutines variant of [ReactiveValueOperations.set].
*
* @author Mark Paluch
* @since 2.2
*/
suspend fun ReactiveValueOperations.setAndAwait(key: K, value: V, timeout: Duration): Boolean =
set(key, value, timeout).awaitSingle()
/**
* Coroutines variant of [ReactiveValueOperations.setIfAbsent].
*
* @author Mark Paluch
* @since 2.2
*/
suspend fun ReactiveValueOperations.setIfAbsentAndAwait(key: K, value: V): Boolean =
setIfAbsent(key, value).awaitSingle()
/**
* Coroutines variant of [ReactiveValueOperations.setIfAbsent].
*
* @author Mark Paluch
* @since 2.2
*/
suspend fun ReactiveValueOperations.setIfAbsentAndAwait(key: K, value: V, timeout: Duration): Boolean =
setIfAbsent(key, value, timeout).awaitSingle()
/**
* Coroutines variant of [ReactiveValueOperations.setIfPresent].
*
* @author Mark Paluch
* @since 2.2
*/
suspend fun ReactiveValueOperations.setIfPresentAndAwait(key: K, value: V): Boolean =
setIfPresent(key, value).awaitSingle()
/**
* Coroutines variant of [ReactiveValueOperations.setIfPresent].
*
* @author Mark Paluch
* @since 2.2
*/
suspend fun ReactiveValueOperations.setIfPresentAndAwait(key: K, value: V, timeout: Duration): Boolean =
setIfPresent(key, value, timeout).awaitSingle()
/**
* Coroutines variant of [ReactiveValueOperations.multiSet].
*
* @author Mark Paluch
* @since 2.2
*/
suspend fun ReactiveValueOperations.multiSetAndAwait(map: Map): Boolean =
multiSet(map).awaitSingle()
/**
* Coroutines variant of [ReactiveValueOperations.multiSetIfAbsent].
*
* @author Mark Paluch
* @since 2.2
*/
suspend fun ReactiveValueOperations.multiSetIfAbsentAndAwait(map: Map): Boolean =
multiSetIfAbsent(map).awaitSingle()
/**
* Coroutines variant of [ReactiveValueOperations.get].
*
* @author Mark Paluch
* @since 2.2
*/
suspend fun ReactiveValueOperations.getAndAwait(key: K): V? =
get(key).awaitFirstOrNull()
/**
* Coroutines variant of [ReactiveValueOperations.getAndSet].
*
* @author Mark Paluch
* @author Christoph Strobl
* @since 2.2
*/
suspend fun ReactiveValueOperations.getAndSetAndAwait(key: K, value: V): V? =
getAndSet(key, value).awaitFirstOrNull()
/**
* Coroutines variant of [ReactiveValueOperations.multiGet].
*
* @author Mark Paluch
* @since 2.2
*/
suspend fun ReactiveValueOperations.multiGetAndAwait(vararg keys: K): List =
multiGet(keys.toCollection(ArrayList())).awaitSingle()
/**
* Coroutines variant of [ReactiveValueOperations.multiGet].
*
* @author Mark Paluch
* @since 2.2
*/
suspend fun ReactiveValueOperations.multiGetAndAwait(keys: Collection): List =
multiGet(keys).awaitSingle()
/**
* Coroutines variant of [ReactiveValueOperations.increment].
*
* @author Mark Paluch
* @since 2.2
*/
suspend fun ReactiveValueOperations.incrementAndAwait(key: K): Long =
increment(key).awaitSingle()
/**
* Coroutines variant of [ReactiveValueOperations.increment].
*
* @author Mark Paluch
* @since 2.2
*/
suspend fun ReactiveValueOperations.incrementAndAwait(key: K, delta: Long): Long =
increment(key, delta).awaitSingle()
/**
* Coroutines variant of [ReactiveValueOperations.increment].
*
* @author Mark Paluch
* @since 2.2
*/
suspend fun ReactiveValueOperations.incrementAndAwait(key: K, delta: Double): Double =
increment(key, delta).awaitSingle()
/**
* Coroutines variant of [ReactiveValueOperations.decrement].
*
* @author Mark Paluch
* @since 2.2
*/
suspend fun ReactiveValueOperations.decrementAndAwait(key: K): Long =
decrement(key).awaitSingle()
/**
* Coroutines variant of [ReactiveValueOperations.decrement].
*
* @author Mark Paluch
* @since 2.2
*/
suspend fun ReactiveValueOperations.decrementAndAwait(key: K, delta: Long): Long =
decrement(key, delta).awaitSingle()
/**
* Coroutines variant of [ReactiveValueOperations.append].
*
* @author Mark Paluch
* @since 2.2
*/
suspend fun ReactiveValueOperations.appendAndAwait(key: K, value: String): Long =
append(key, value).awaitSingle()
/**
* Coroutines variant of [ReactiveValueOperations.get].
*
* @author Mark Paluch
* @since 2.2
*/
suspend fun ReactiveValueOperations.getAndAwait(key: K, start: Long, end: Long): String? =
get(key, start, end).awaitFirstOrNull()
/**
* Coroutines variant of [ReactiveValueOperations.set].
*
* @author Mark Paluch
* @since 2.2
*/
suspend fun ReactiveValueOperations.setAndAwait(key: K, value: V, offset: Long): Long =
set(key, value, offset).awaitSingle()
/**
* Coroutines variant of [ReactiveValueOperations.size].
*
* @author Mark Paluch
* @author Christoph Strobl
* @since 2.2
*/
suspend fun ReactiveValueOperations.sizeAndAwait(key: K): Long =
size(key).awaitSingle()
/**
* Coroutines variant of [ReactiveValueOperations.setBit].
*
* @author Mark Paluch
* @since 2.2
*/
suspend fun ReactiveValueOperations.setBitAndAwait(key: K, offset: Long, value: Boolean): Boolean =
setBit(key, offset, value).awaitSingle()
/**
* Coroutines variant of [ReactiveValueOperations.getBit].
*
* @author Mark Paluch
* @since 2.2
*/
suspend fun ReactiveValueOperations.getBitAndAwait(key: K, offset: Long): Boolean =
getBit(key, offset).awaitSingle()
/**
* Coroutines variant of [ReactiveValueOperations.bitField].
*
* @author Mark Paluch
* @since 2.2
*/
suspend fun ReactiveValueOperations.bitFieldAndAwait(key: K, commands: BitFieldSubCommands): List =
bitField(key, commands).awaitSingle()
/**
* Coroutines variant of [ReactiveValueOperations.delete].
*
* @author Mark Paluch
* @since 2.2
*/
suspend fun ReactiveValueOperations.deleteAndAwait(key: K): Boolean =
delete(key).awaitSingle()