DATAKV-12
+ RedisList implements BlockingDeque
This commit is contained in:
@@ -447,4 +447,50 @@ public class DefaultRedisList<E> extends AbstractRedisCollection<E> implements R
|
||||
public E take() throws InterruptedException {
|
||||
return poll(0, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// BlockingDeque
|
||||
//
|
||||
|
||||
@Override
|
||||
public boolean offerFirst(E e, long timeout, TimeUnit unit) throws InterruptedException {
|
||||
return offerFirst(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean offerLast(E e, long timeout, TimeUnit unit) throws InterruptedException {
|
||||
return offerLast(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public E pollFirst(long timeout, TimeUnit unit) throws InterruptedException {
|
||||
return poll(timeout, unit);
|
||||
}
|
||||
|
||||
@Override
|
||||
public E pollLast(long timeout, TimeUnit unit) throws InterruptedException {
|
||||
E element = listOps.rightPop(timeout, unit);
|
||||
return (element == null ? null : element);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putFirst(E e) throws InterruptedException {
|
||||
add(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putLast(E e) throws InterruptedException {
|
||||
put(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public E takeFirst() throws InterruptedException {
|
||||
return take();
|
||||
}
|
||||
|
||||
@Override
|
||||
public E takeLast() throws InterruptedException {
|
||||
return pollLast(0, TimeUnit.SECONDS);
|
||||
}
|
||||
}
|
||||
@@ -15,9 +15,9 @@
|
||||
*/
|
||||
package org.springframework.data.keyvalue.redis.util;
|
||||
|
||||
import java.util.Deque;
|
||||
import java.util.List;
|
||||
import java.util.Queue;
|
||||
import java.util.concurrent.BlockingDeque;
|
||||
|
||||
/**
|
||||
* Redis extension for the {@link List} contract. Supports {@link List} and {@link Queue} specific
|
||||
@@ -25,7 +25,7 @@ import java.util.Queue;
|
||||
*
|
||||
* @author Costin Leau
|
||||
*/
|
||||
public interface RedisList<E> extends RedisStore<String>, List<E>, Deque<E> {
|
||||
public interface RedisList<E> extends RedisStore<String>, List<E>, BlockingDeque<E> {
|
||||
|
||||
List<E> range(long start, long end);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user