DATAKV-12

+ RedisList implements BlockingDeque
This commit is contained in:
Costin Leau
2010-12-06 11:55:52 +02:00
parent 32cdf5be9a
commit b9d3d77bc6
2 changed files with 48 additions and 2 deletions

View File

@@ -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);
}
}

View File

@@ -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);