Skip to content

Commit

Permalink
Merge pull request #873 from yisraelU/Len-Fxns
Browse files Browse the repository at this point in the history
removed unnecessary option wrapping
  • Loading branch information
yisraelU authored May 17, 2024
2 parents 84be353 + 29a1f13 commit b760f1a
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 27 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,8 @@ jobs:
- name: "Run tests and compile documentation 🚀"
run: nix develop -c sbt 'buildRedis4Cats'

- name: "Test for Binary Compatibility 📦"
run: nix develop -c sbt 'mimaReportBinaryIssuesIfRelevant'

- name: "Shutting down Redis 🐳"
run: docker-compose down
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,6 @@ lazy val microsite = project

// CI build
addCommandAlias("buildDoc", ";++2.13.12;mdoc;doc")
addCommandAlias("buildRedis4Cats", ";mimaReportBinaryIssuesIfRelevant;+test;buildDoc")
addCommandAlias("buildRedis4Cats", ";+test;buildDoc")
addCommandAlias("buildSite", ";doc;makeMicrosite")
addCommandAlias("publishSite", ";doc;publishMicrosite")
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ trait HashGetter[F[_], K, V] {
def hmGet(key: K, field: K, fields: K*): F[Map[K, V]]
def hKeys(key: K): F[List[K]]
def hVals(key: K): F[List[V]]
def hStrLen(key: K, field: K): F[Option[Long]]
def hLen(key: K): F[Option[Long]]
def hStrLen(key: K, field: K): F[Long]
def hLen(key: K): F[Long]
}

trait HashSetter[F[_], K, V] {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ trait ListBlocking[F[_], K, V] {

trait ListGetter[F[_], K, V] {
def lIndex(key: K, index: Long): F[Option[V]]
def lLen(key: K): F[Option[Long]]
def lLen(key: K): F[Long]
def lRange(key: K, start: Long, stop: Long): F[List[V]]
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ import scala.concurrent.duration.Duration
trait SortedSetCommands[F[_], K, V] extends SortedSetGetter[F, K, V] with SortedSetSetter[F, K, V]

trait SortedSetGetter[F[_], K, V] {
def zCard(key: K): F[Option[Long]]
def zCount[T: Numeric](key: K, range: ZRange[T]): F[Option[Long]]
def zLexCount(key: K, range: ZRange[V]): F[Option[Long]]
def zCard(key: K): F[Long]
def zCount[T: Numeric](key: K, range: ZRange[T]): F[Long]
def zLexCount(key: K, range: ZRange[V]): F[Long]
def zRange(key: K, start: Long, stop: Long): F[List[V]]
def zRangeByLex(key: K, range: ZRange[V], limit: Option[RangeLimit]): F[List[V]]
def zRangeByScore[T: Numeric](key: K, range: ZRange[T], limit: Option[RangeLimit]): F[List[V]]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ trait Getter[F[_], K, V] {
def get(key: K): F[Option[V]]
def getEx(key: K, getExArg: GetExArg): F[Option[V]]
def getRange(key: K, start: Long, end: Long): F[Option[V]]
def strLen(key: K): F[Option[Long]]
def strLen(key: K): F[Long]
}

trait Setter[F[_], K, V] {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -703,8 +703,8 @@ private[redis4cats] class BaseRedis[F[_]: FutureLift: MonadThrow: Log, K, V](
override def getRange(key: K, start: Long, end: Long): F[Option[V]] =
async.flatMap(_.getrange(key, start, end).futureLift.map(Option.apply))

override def strLen(key: K): F[Option[Long]] =
async.flatMap(_.strlen(key).futureLift.map(x => Option(Long.unbox(x))))
override def strLen(key: K): F[Long] =
async.flatMap(_.strlen(key).futureLift.map(x => Long.unbox(x)))

override def mGet(keys: Set[K]): F[Map[K, V]] =
async
Expand Down Expand Up @@ -741,11 +741,11 @@ private[redis4cats] class BaseRedis[F[_]: FutureLift: MonadThrow: Log, K, V](
override def hVals(key: K): F[List[V]] =
async.flatMap(_.hvals(key).futureLift.map(_.asScala.toList))

override def hStrLen(key: K, field: K): F[Option[Long]] =
async.flatMap(_.hstrlen(key, field).futureLift.map(x => Option(Long.unbox(x))))
override def hStrLen(key: K, field: K): F[Long] =
async.flatMap(_.hstrlen(key, field).futureLift.map(x => Long.unbox(x)))

override def hLen(key: K): F[Option[Long]] =
async.flatMap(_.hlen(key).futureLift.map(x => Option(Long.unbox(x))))
override def hLen(key: K): F[Long] =
async.flatMap(_.hlen(key).futureLift.map(x => Long.unbox(x)))

override def hSet(key: K, field: K, value: V): F[Boolean] =
async.flatMap(_.hset(key, field, value).futureLift.map(x => Boolean.box(x)))
Expand Down Expand Up @@ -821,8 +821,8 @@ private[redis4cats] class BaseRedis[F[_]: FutureLift: MonadThrow: Log, K, V](
override def lIndex(key: K, index: Long): F[Option[V]] =
async.flatMap(_.lindex(key, index).futureLift.map(Option.apply))

override def lLen(key: K): F[Option[Long]] =
async.flatMap(_.llen(key).futureLift.map(x => Option(Long.unbox(x))))
override def lLen(key: K): F[Long] =
async.flatMap(_.llen(key).futureLift.map(x => Long.unbox(x)))

override def lRange(key: K, start: Long, stop: Long): F[List[V]] =
async.flatMap(_.lrange(key, start, stop).futureLift.map(_.asScala.toList))
Expand Down Expand Up @@ -1074,14 +1074,14 @@ private[redis4cats] class BaseRedis[F[_]: FutureLift: MonadThrow: Log, K, V](
res.map(x => Long.box(x))
}

override def zCard(key: K): F[Option[Long]] =
async.flatMap(_.zcard(key).futureLift.map(x => Option(Long.unbox(x))))
override def zCard(key: K): F[Long] =
async.flatMap(_.zcard(key).futureLift.map(x => Long.unbox(x)))

override def zCount[T: Numeric](key: K, range: ZRange[T]): F[Option[Long]] =
async.flatMap(_.zcount(key, range.asJavaRange).futureLift.map(x => Option(Long.unbox(x))))
override def zCount[T: Numeric](key: K, range: ZRange[T]): F[Long] =
async.flatMap(_.zcount(key, range.asJavaRange).futureLift.map(x => Long.unbox(x)))

override def zLexCount(key: K, range: ZRange[V]): F[Option[Long]] =
async.flatMap(_.zlexcount(key, JRange.create[V](range.start, range.end)).futureLift.map(x => Option(Long.unbox(x))))
override def zLexCount(key: K, range: ZRange[V]): F[Long] =
async.flatMap(_.zlexcount(key, JRange.create[V](range.start, range.end)).futureLift.map(x => Long.unbox(x)))

override def zRange(key: K, start: Long, stop: Long): F[List[V]] =
async.flatMap(_.zrange(key, start, stop).futureLift.map(_.asScala.toList))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ trait TestScenarios { self: FunSuite =>
x <- redis.lRange(testKey, 0, 10)
_ <- IO(assertEquals(x, List("one", "two", "three")))
y <- redis.lLen(testKey)
_ <- IO(assert(y.contains(3L)))
_ <- IO(assert(y == 3L))
a <- redis.lPop(testKey)
_ <- IO(assert(a.contains("one")))
b <- redis.rPop(testKey)
Expand Down Expand Up @@ -184,20 +184,20 @@ trait TestScenarios { self: FunSuite =>
_ <- IO(assertEquals(minPop2, List(scoreWithValue1)))
maxPop2 <- redis.zPopMax(testKey, 1)
_ <- IO(assertEquals(maxPop2, List(scoreWithValue2)))
_ <- redis.zCard(testKey).map(card => assert(card.contains(0L)))
_ <- redis.zCard(testKey).map(card => assert(card == 0L))
_ <- redis.zAdd(testKey, args = None, scoreWithValue1, scoreWithValue2)
minBPop2 <- redis.bzPopMin(timeout, NonEmptyList.one(testKey))
_ <- IO(assert(minBPop2.contains((testKey, scoreWithValue1))))
maxBPop2 <- redis.bzPopMax(timeout, NonEmptyList.one(testKey))
_ <- IO(assert(maxBPop2.contains((testKey, scoreWithValue2))))
_ <- redis.zCard(testKey).map(card => assert(card.contains(0L)))
_ <- redis.zCard(testKey).map(card => assert(card == 0L))
_ <- redis.zAdd(testKey, args = None, scoreWithValue1, scoreWithValue2)
x <- redis.zRevRangeByScore(testKey, ZRange(0, 2), limit = None)
_ <- IO(assertEquals(x, List(1L)))
y <- redis.zCard(testKey)
_ <- IO(assert(y.contains(2L)))
_ <- IO(assert(y == 2L))
z <- redis.zCount(testKey, ZRange(0, 1))
_ <- IO(assert(z.contains(1L)))
_ <- IO(assert(z == 1L))
_ <- redis.zAdd(otherTestKey, args = None, scoreWithValue1, scoreWithValue3)
zUnion <- redis.zUnion(args = None, testKey, otherTestKey)
_ <- IO(assertEquals(zUnion, List(1L, 2L, 3L)))
Expand Down
1 change: 1 addition & 0 deletions project/MimaVersionPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ object MimaVersionPlugin extends AutoPlugin {
val tags = scala.util
.Try("git tag --list".!!.split("\n").map(_.trim))
.getOrElse(new Array[String](0))
println(tags.mkString("\n"))

// in semver, we allow breakage in minor releases if major is 0, otherwise not
val Pattern =
Expand Down

0 comments on commit b760f1a

Please sign in to comment.