Skip to content

Commit 7f46ee0

Browse files
authored
Name threshold paramter correct for XTRIM command (zio#1053)
1 parent 6e4ab0c commit 7f46ee0

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

modules/redis/src/main/scala/zio/redis/api/Streams.scala

+10-11
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
*/
1616

1717
package zio.redis.api
18-
1918
import zio._
2019
import zio.redis.Input._
2120
import zio.redis.Output._
@@ -1027,51 +1026,51 @@ trait Streams[G[+_]] extends RedisEnvironment[G] {
10271026
*
10281027
* @param key
10291028
* ID of the stream
1030-
* @param count
1031-
* stream length
1029+
* @param threshold
1030+
* Evicts entries as long as the stream's length exceeds the specified threshold
10321031
* @param approximate
10331032
* flag that indicates if the stream length should be exactly count or few tens of entries more
10341033
* @return
10351034
* the number of entries deleted from the stream.
10361035
*/
10371036
final def xTrimWithMaxLen[SK: Schema](
10381037
key: SK,
1039-
count: Long,
1038+
threshold: Long,
10401039
approximate: Boolean = false,
10411040
limit: Option[Long] = None
10421041
): G[Long] =
10431042
if (approximate) {
10441043
val command = RedisCommand(XTrim, Tuple2(ArbitraryKeyInput[SK](), MaxLenApproxInput), LongOutput)
1045-
command.run((key, CappedStreamType.MaxLenApprox(count, limit)))
1044+
command.run((key, CappedStreamType.MaxLenApprox(threshold, limit)))
10461045
} else {
10471046
val command = RedisCommand(XTrim, Tuple2(ArbitraryKeyInput[SK](), MaxLenExactInput), LongOutput)
1048-
command.run((key, CappedStreamType.MaxLenExact(count)))
1047+
command.run((key, CappedStreamType.MaxLenExact(threshold)))
10491048
}
10501049

10511050
/**
10521051
* Trims the stream to a given number of items, evicting older items (items with lower IDs) if needed.
10531052
*
10541053
* @param key
10551054
* ID of the stream
1056-
* @param minId
1057-
* minimal stream id
1055+
* @param threshold
1056+
* Evicts entries with IDs lower than threshold, where threshold is a stream ID
10581057
* @param approximate
10591058
* flag that indicates if the stream length should be exactly count or few tens of entries more
10601059
* @return
10611060
* the number of entries deleted from the stream.
10621061
*/
10631062
final def xTrimWithMinId[SK: Schema, I: Schema](
10641063
key: SK,
1065-
minId: I,
1064+
threshold: I,
10661065
approximate: Boolean = false,
10671066
limit: Option[Long] = None
10681067
): G[Long] =
10691068
if (approximate) {
10701069
val command = RedisCommand(XTrim, Tuple2(ArbitraryKeyInput[SK](), MinIdApproxInput[I]()), LongOutput)
1071-
command.run((key, CappedStreamType.MinIdApprox(minId, limit)))
1070+
command.run((key, CappedStreamType.MinIdApprox(threshold, limit)))
10721071
} else {
10731072
val command = RedisCommand(XTrim, Tuple2(ArbitraryKeyInput[SK](), MinIdExactInput[I]()), LongOutput)
1074-
command.run((key, CappedStreamType.MinIdExact(minId)))
1073+
command.run((key, CappedStreamType.MinIdExact(threshold)))
10751074
}
10761075
}
10771076

0 commit comments

Comments
 (0)