Skip to content

Commit cdb0c03

Browse files
Remove deprecated api lists (#1161)
1 parent cfece19 commit cdb0c03

File tree

2 files changed

+18
-146
lines changed

2 files changed

+18
-146
lines changed

modules/redis-it/src/test/scala/zio/redis/ListSpec.scala

Lines changed: 0 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -161,79 +161,6 @@ trait ListSpec extends IntegrationSpec {
161161
} yield assert(push)(isLeft(isSubtype[RedisError.WrongType](anything)))
162162
}
163163
),
164-
suite("poppush")(
165-
test("rPopLPush") {
166-
for {
167-
redis <- ZIO.service[Redis]
168-
key <- uuid
169-
dest <- uuid
170-
_ <- redis.rPush(key, "one", "two", "three")
171-
_ <- redis.rPush(dest, "four")
172-
_ <- redis.rPopLPush(key, dest).returning[String]
173-
r <- redis.lRange(key, 0 to -1).returning[String]
174-
l <- redis.lRange(dest, 0 to -1).returning[String]
175-
} yield assert(r)(equalTo(Chunk("one", "two"))) && assert(l)(equalTo(Chunk("three", "four")))
176-
},
177-
test("rPopLPush nothing when source does not exist") {
178-
for {
179-
redis <- ZIO.service[Redis]
180-
key <- uuid
181-
dest <- uuid
182-
_ <- redis.rPush(dest, "four")
183-
_ <- redis.rPopLPush(key, dest).returning[String]
184-
l <- redis.lRange(dest, 0 to -1).returning[String]
185-
} yield assert(l)(equalTo(Chunk("four")))
186-
},
187-
test("rPopLPush error when not list") {
188-
for {
189-
redis <- ZIO.service[Redis]
190-
key <- uuid
191-
dest <- uuid
192-
value <- uuid
193-
_ <- redis.set(key, value)
194-
rpp <- redis.rPopLPush(key, dest).returning[String].either
195-
} yield assert(rpp)(isLeft)
196-
}
197-
) @@ clusterExecutorUnsupported,
198-
suite("blocking poppush")(
199-
test("brPopLPush") {
200-
for {
201-
redis <- ZIO.service[Redis]
202-
key <- uuid
203-
dest <- uuid
204-
_ <- redis.rPush(key, "one", "two", "three")
205-
_ <- redis.rPush(dest, "four")
206-
fiber <- redis.brPopLPush(key, dest, 1.seconds).returning[String].fork
207-
_ <- TestClock.adjust(1.second)
208-
_ <- fiber.join
209-
r <- redis.lRange(key, 0 to -1).returning[String]
210-
l <- redis.lRange(dest, 0 to -1).returning[String]
211-
} yield assert(r)(equalTo(Chunk("one", "two"))) && assert(l)(equalTo(Chunk("three", "four")))
212-
},
213-
test("brPopLPush block for 1 second when source does not exist") {
214-
for {
215-
redis <- ZIO.service[Redis]
216-
key <- uuid
217-
dest <- uuid
218-
_ <- redis.rPush(dest, "four")
219-
startTime <- currentTime(TimeUnit.SECONDS)
220-
fiber <- redis.brPopLPush(key, dest, 1.seconds).returning[String].fork
221-
_ <- TestClock.adjust(1.second)
222-
s <- fiber.join
223-
endTime <- currentTime(TimeUnit.SECONDS)
224-
} yield assert(s)(isNone) && assert(endTime - startTime)(isGreaterThanEqualTo(1L))
225-
},
226-
test("brPopLPush error when not list") {
227-
for {
228-
redis <- ZIO.service[Redis]
229-
key <- uuid
230-
dest <- uuid
231-
value <- uuid
232-
_ <- redis.set(key, value)
233-
bpp <- redis.brPopLPush(key, dest, 1.seconds).returning[String].either
234-
} yield assert(bpp)(isLeft)
235-
}
236-
) @@ clusterExecutorUnsupported,
237164
suite("remove")(
238165
test("lRem 2 elements moving from head") {
239166
for {

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

Lines changed: 18 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -123,37 +123,6 @@ trait Lists[G[+_]] extends RedisEnvironment[G] {
123123
}
124124
}
125125

126-
/**
127-
* Pops an element from the list stored at source, pushes it to the list stored at destination; or block until one is
128-
* available. This is the blocking variant of [[zio.redis.api.Lists#rPopLPush]].
129-
*
130-
* @param source
131-
* the key identifier of the source list
132-
* @param destination
133-
* the key identifier of the target list
134-
* @param timeout
135-
* the maximum time to wait for an element to be available. A timeout of zero can be used to block indefinitely
136-
* @return
137-
* the element being popped from source and pushed to destination. If timeout is reached, an empty reply is
138-
* returned.
139-
*/
140-
final def brPopLPush[S: Schema, D: Schema](
141-
source: S,
142-
destination: D,
143-
timeout: Duration
144-
): ResultBuilder1[Option, G] =
145-
new ResultBuilder1[Option, G] {
146-
def returning[V: Schema]: G[Option[V]] = {
147-
val command = RedisCommand(
148-
BrPopLPush,
149-
Tuple3(ArbitraryValueInput[S](), ArbitraryValueInput[D](), DurationSecondsInput),
150-
OptionalOutput(ArbitraryOutput[V]())
151-
)
152-
153-
command.run((source, destination, timeout))
154-
}
155-
}
156-
157126
/**
158127
* Returns the element at index in the list stored at key.
159128
*
@@ -463,28 +432,6 @@ trait Lists[G[+_]] extends RedisEnvironment[G] {
463432
RedisCommand(RPop, ArbitraryKeyInput[K](), OptionalOutput(ArbitraryOutput[V]())).run(key)
464433
}
465434

466-
/**
467-
* Atomically removes the last element in the list stored at source, prepends it to the list stored at destination and
468-
* returns it. If source and destination are the same, the operation is equivalent to removing the last element from
469-
* the list and pushing it as first element of the same list, so it can be considered as a list rotation command.
470-
*
471-
* @param source
472-
* the key identifier of the source list
473-
* @param destination
474-
* the key identifier of the destination list
475-
* @return
476-
* the element being popped and pushed. If source does not exist, empty is returned and no operation is performed.
477-
*/
478-
final def rPopLPush[S: Schema, D: Schema](source: S, destination: D): ResultBuilder1[Option, G] =
479-
new ResultBuilder1[Option, G] {
480-
def returning[V: Schema]: G[Option[V]] =
481-
RedisCommand(
482-
RPopLPush,
483-
Tuple2(ArbitraryValueInput[S](), ArbitraryValueInput[D]()),
484-
OptionalOutput(ArbitraryOutput[V]())
485-
).run((source, destination))
486-
}
487-
488435
/**
489436
* Appends one or more elements to the list stored at key. If key does not exist, it is created as empty list before
490437
* performing the push operation.
@@ -525,24 +472,22 @@ trait Lists[G[+_]] extends RedisEnvironment[G] {
525472
}
526473

527474
private[redis] object Lists {
528-
final val BlMove = "BLMOVE"
529-
final val BlPop = "BLPOP"
530-
final val BrPop = "BRPOP"
531-
final val BrPopLPush = "BRPOPLPUSH"
532-
final val LIndex = "LINDEX"
533-
final val LInsert = "LINSERT"
534-
final val LLen = "LLEN"
535-
final val LMove = "LMOVE"
536-
final val LPop = "LPOP"
537-
final val LPos = "LPOS"
538-
final val LPush = "LPUSH"
539-
final val LPushX = "LPUSHX"
540-
final val LRange = "LRANGE"
541-
final val LRem = "LREM"
542-
final val LSet = "LSET"
543-
final val LTrim = "LTRIM"
544-
final val RPop = "RPOP"
545-
final val RPopLPush = "RPOPLPUSH"
546-
final val RPush = "RPUSH"
547-
final val RPushX = "RPUSHX"
475+
final val BlMove = "BLMOVE"
476+
final val BlPop = "BLPOP"
477+
final val BrPop = "BRPOP"
478+
final val LIndex = "LINDEX"
479+
final val LInsert = "LINSERT"
480+
final val LLen = "LLEN"
481+
final val LMove = "LMOVE"
482+
final val LPop = "LPOP"
483+
final val LPos = "LPOS"
484+
final val LPush = "LPUSH"
485+
final val LPushX = "LPUSHX"
486+
final val LRange = "LRANGE"
487+
final val LRem = "LREM"
488+
final val LSet = "LSET"
489+
final val LTrim = "LTRIM"
490+
final val RPop = "RPOP"
491+
final val RPush = "RPUSH"
492+
final val RPushX = "RPUSHX"
548493
}

0 commit comments

Comments
 (0)