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.ReactiveZSetOperationsExtensions.kt Maven / Gradle / Ivy
/*
* Copyright 2019-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 kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.reactive.asFlow
import kotlinx.coroutines.reactive.awaitFirstOrNull
import kotlinx.coroutines.reactive.awaitSingle
import org.springframework.data.domain.Range
import org.springframework.data.redis.connection.RedisZSetCommands
import org.springframework.data.redis.connection.RedisZSetCommands.Limit
import org.springframework.data.redis.core.ZSetOperations.*
/**
* Coroutines variant of [ReactiveZSetOperations.add].
*
* @author Mark Paluch
* @since 2.2
*/
suspend fun ReactiveZSetOperations.addAndAwait(key: K, value: V, score: Double): Boolean =
add(key, value, score).awaitSingle()
/**
* Coroutines variant of [ReactiveZSetOperations.addAll].
*
* @author Mark Paluch
* @since 2.2
*/
suspend fun ReactiveZSetOperations.addAllAndAwait(key: K, values: Collection>): Long =
addAll(key, values).awaitSingle()
/**
* Coroutines variant of [ReactiveZSetOperations.remove].
*
* @author Mark Paluch
* @since 2.2
*/
suspend fun ReactiveZSetOperations.removeAndAwait(key: K, vararg values: Any): Long =
remove(key, *values).awaitSingle()
/**
* Coroutines variant of [ReactiveZSetOperations.incrementScore].
*
* @author Mark Paluch
* @since 2.2
*/
suspend fun ReactiveZSetOperations.incrementScoreAndAwait(key: K, value: V, score: Double): Double =
incrementScore(key, value, score).awaitSingle()
/**
* Coroutines variant of [ReactiveZSetOperations.rank].
*
* @author Mark Paluch
* @since 2.2
*/
suspend fun ReactiveZSetOperations.rankAndAwait(key: K, value: V): Long? =
rank(key, value).awaitFirstOrNull()
/**
* Coroutines variant of [ReactiveZSetOperations.reverseRank].
*
* @author Mark Paluch
* @since 2.2
*/
suspend fun ReactiveZSetOperations.reverseRankAndAwait(key: K, value: V): Long? =
reverseRank(key, value).awaitFirstOrNull()
/**
* Coroutines variant of [ReactiveZSetOperations.range].
*
* @author Sebastien Deleuze
* @since 2.2
*/
fun ReactiveZSetOperations.rangeAsFlow(key: K, range: Range): Flow =
range(key, range).asFlow()
/**
* Coroutines variant of [ReactiveZSetOperations.rangeWithScores].
*
* @author Sebastien Deleuze
* @since 2.2
*/
fun ReactiveZSetOperations.rangeWithScoresAsFlow(key: K, range: Range): Flow> =
rangeWithScores(key, range).asFlow()
/**
* Coroutines variant of [ReactiveZSetOperations.rangeByScore].
*
* @author Sebastien Deleuze
* @since 2.2
*/
fun ReactiveZSetOperations.rangeByScoreAsFlow(key: K, range: Range, limit: Limit = Limit.unlimited()): Flow =
rangeByScore(key, range, limit).asFlow()
/**
* Coroutines variant of [ReactiveZSetOperations.rangeByScoreWithScores].
*
* @author Sebastien Deleuze
* @since 2.2
*/
fun ReactiveZSetOperations.rangeByScoreWithScoresAsFlow(key: K, range: Range, limit: Limit = Limit.unlimited()): Flow> =
rangeByScoreWithScores(key, range, limit).asFlow()
/**
* Coroutines variant of [ReactiveZSetOperations.reverseRange].
*
* @author Sebastien Deleuze
* @since 2.2
*/
fun ReactiveZSetOperations.reverseRangeAsFlow(key: K, range: Range): Flow =
reverseRange(key, range).asFlow()
/**
* Coroutines variant of [ReactiveZSetOperations.reverseRangeWithScores].
*
* @author Sebastien Deleuze
* @since 2.2
*/
fun ReactiveZSetOperations.reverseRangeWithScoresAsFlow(key: K, range: Range): Flow> =
reverseRangeWithScores(key, range).asFlow()
/**
* Coroutines variant of [ReactiveZSetOperations.reverseRangeByScore].
*
* @author Sebastien Deleuze
* @since 2.2
*/
fun ReactiveZSetOperations.reverseRangeByScoreAsFlow(key: K, range: Range, limit: Limit = Limit.unlimited()): Flow =
reverseRangeByScore(key, range, limit).asFlow()
/**
* Coroutines variant of [ReactiveZSetOperations.reverseRangeByScoreWithScores].
*
* @author Sebastien Deleuze
* @since 2.2
*/
fun ReactiveZSetOperations.reverseRangeByScoreWithScoresAsFlow(key: K, range: Range, limit: Limit = Limit.unlimited()): Flow> =
reverseRangeByScoreWithScores(key, range, limit).asFlow()
/**
* Coroutines variant of [ReactiveZSetOperations.count].
*
* @author Mark Paluch
* @since 2.2
*/
suspend fun ReactiveZSetOperations.countAndAwait(key: K, range: Range): Long =
count(key, range).awaitSingle()
/**
* Coroutines variant of [ReactiveZSetOperations.size].
*
* @author Wonwoo Lee
* @since 2.3
*/
suspend fun ReactiveZSetOperations.sizeAndAwait(key: K): Long =
size(key).awaitSingle()
/**
* Coroutines variant of [ReactiveZSetOperations.score].
*
* @author Mark Paluch
* @since 2.2
*/
suspend fun ReactiveZSetOperations.scoreAndAwait(key: K, value: V): Double? =
score(key, value).awaitFirstOrNull()
/**
* Coroutines variant of [ReactiveZSetOperations.removeRange].
*
* @author Mark Paluch
* @since 2.2
*/
suspend fun ReactiveZSetOperations.removeRangeAndAwait(key: K, range: Range): Long =
removeRange(key, range).awaitSingle()
/**
* Coroutines variant of [ReactiveZSetOperations.removeRangeByLex].
*
* @author Christoph Strobl
* @since 2.5
*/
suspend fun ReactiveZSetOperations.removeRangeByLexAndAwait(key: K, range: Range): Long =
removeRangeByLex(key, range).awaitSingle()
/**
* Coroutines variant of [ReactiveZSetOperations.removeRangeByScore].
*
* @author Mark Paluch
* @since 2.2
*/
suspend fun ReactiveZSetOperations.removeRangeByScoreAndAwait(key: K, range: Range): Long =
removeRangeByScore(key, range).awaitSingle()
/**
* Coroutines variant of [ReactiveZSetOperations.unionAndStore].
*
* @author Mark Paluch
* @since 2.2
*/
suspend fun ReactiveZSetOperations.unionAndStoreAndAwait(key: K, otherKey: K, destKey: K): Long =
unionAndStore(key, otherKey, destKey).awaitSingle()
/**
* Coroutines variant of [ReactiveZSetOperations.unionAndStore].
*
* @author Mark Paluch
* @since 2.2
*/
suspend fun ReactiveZSetOperations.unionAndStoreAndAwait(key: K, otherKeys: Collection, destKey: K): Long =
unionAndStore(key, otherKeys, destKey).awaitSingle()
/**
* Coroutines variant of [ReactiveZSetOperations.unionAndStore].
*
* @author Mark Paluch
* @since 2.2
*/
suspend fun ReactiveZSetOperations.unionAndStoreAndAwait(key: K, otherKeys: Collection, destKey: K, aggregate: RedisZSetCommands.Aggregate): Long =
unionAndStore(key, otherKeys, destKey, aggregate).awaitSingle()
/**
* Coroutines variant of [ReactiveZSetOperations.unionAndStore].
*
* @author Mark Paluch
* @since 2.2
*/
suspend fun ReactiveZSetOperations.unionAndStoreAndAwait(key: K, otherKeys: Collection, destKey: K, aggregate: RedisZSetCommands.Aggregate, weights: RedisZSetCommands.Weights): Long =
unionAndStore(key, otherKeys, destKey, aggregate, weights).awaitSingle()
/**
* Coroutines variant of [ReactiveZSetOperations.intersectAndStore].
*
* @author Mark Paluch
* @since 2.2
*/
suspend fun ReactiveZSetOperations.intersectAndStoreAndAwait(key: K, otherKey: K, destKey: K): Long =
intersectAndStore(key, otherKey, destKey).awaitSingle()
/**
* Coroutines variant of [ReactiveZSetOperations.intersectAndStore].
*
* @author Mark Paluch
* @since 2.2
*/
suspend fun ReactiveZSetOperations.intersectAndStoreAndAwait(key: K, otherKeys: Collection, destKey: K): Long =
intersectAndStore(key, otherKeys, destKey).awaitSingle()
/**
* Coroutines variant of [ReactiveZSetOperations.intersectAndStore].
*
* @author Mark Paluch
* @since 2.2
*/
suspend fun ReactiveZSetOperations.intersectAndStoreAndAwait(key: K, otherKeys: Collection, destKey: K, aggregate: RedisZSetCommands.Aggregate): Long =
intersectAndStore(key, otherKeys, destKey, aggregate).awaitSingle()
/**
* Coroutines variant of [ReactiveZSetOperations.intersectAndStore].
*
* @author Mark Paluch
* @since 2.2
*/
suspend fun ReactiveZSetOperations.intersectAndStoreAndAwait(key: K, otherKeys: Collection, destKey: K, aggregate: RedisZSetCommands.Aggregate, weights: RedisZSetCommands.Weights): Long =
intersectAndStore(key, otherKeys, destKey, aggregate, weights).awaitSingle()
/**
* Coroutines variant of [ReactiveZSetOperations.rangeByLex].
*
* @author Wonwoo Lee
* @since 2.3
*/
fun ReactiveZSetOperations.rangeByLexAndAwait(key: K, range: Range, limit: Limit = Limit.unlimited()): Flow =
rangeByLex(key, range, limit).asFlow()
/**
* Coroutines variant of [ReactiveZSetOperations.reverseRangeByLex].
*
* @author Wonwoo Lee
* @since 2.3
*/
fun ReactiveZSetOperations.reverseRangeByLexAndAwait(key: K, range: Range, limit: Limit = Limit.unlimited()): Flow =
reverseRangeByLex(key, range, limit).asFlow()
/**
* Coroutines variant of [ReactiveZSetOperations.delete].
*
* @author Mark Paluch
* @since 2.2
*/
suspend fun ReactiveZSetOperations.deleteAndAwait(key: K): Boolean =
delete(key).awaitSingle()