|
|
package com.yoho.unions.common.redis;
|
|
|
|
|
|
import org.springframework.data.redis.core.ListOperations;
|
|
|
import org.springframework.data.redis.core.RedisOperations;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import java.util.Collection;
|
|
|
import java.util.List;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
/**
|
|
|
* Created by xjipeng on 16/2/11.
|
|
|
*/
|
|
|
public class YHListOperations<K,V> implements ListOperations<K, V> {
|
|
|
|
|
|
@Resource(name = "yhRedisTemplate")
|
|
|
private ListOperations<K, V> listOperations;
|
|
|
|
|
|
@Resource(name = "yhRedisTemplateReadOnly")
|
|
|
private ListOperations<K, V> listOperationsReadOnly;
|
|
|
|
|
|
@Override
|
|
|
public List<V> range(K key, long start, long end) {
|
|
|
return listOperationsReadOnly.range(key, start, end);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void trim(K key, long start, long end) {
|
|
|
listOperations.trim(key,start,end);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public Long size(K key) {
|
|
|
return listOperationsReadOnly.size(key);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public Long leftPush(K key, V value) {
|
|
|
return listOperations.leftPush(key,value);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public Long leftPushAll(K key, V... values) {
|
|
|
return listOperations.leftPushAll(key, values);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Insert all {@literal values} at the head of the list stored at {@literal key}.
|
|
|
*
|
|
|
* @param key must not be {@literal null}.
|
|
|
* @param values must not be {@literal empty} nor contain {@literal null} values.
|
|
|
* @return
|
|
|
* @since 1.5
|
|
|
*/
|
|
|
@Override
|
|
|
public Long leftPushAll(K key, Collection<V> values) {
|
|
|
return listOperations.leftPushAll( key, values);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public Long leftPushIfPresent(K key, V value) {
|
|
|
return listOperations.leftPushIfPresent(key, value);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public Long leftPush(K key, V pivot, V value) {
|
|
|
return listOperations.leftPush(key, pivot, value);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public Long rightPush(K key, V value) {
|
|
|
return listOperations.rightPush( key, value);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public Long rightPushAll(K key, V... values) {
|
|
|
return listOperations.rightPushAll( key, values);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Insert all {@literal values} at the tail of the list stored at {@literal key}.
|
|
|
*
|
|
|
* @param key must not be {@literal null}.
|
|
|
* @param values must not be {@literal empty} nor contain {@literal null} values.
|
|
|
* @return
|
|
|
* @since 1.5
|
|
|
*/
|
|
|
@Override
|
|
|
public Long rightPushAll(K key, Collection<V> values) {
|
|
|
return listOperations.rightPushAll(key, values);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public Long rightPushIfPresent(K key, V value) {
|
|
|
return listOperations.rightPushIfPresent(key, value);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public Long rightPush(K key, V pivot, V value) {
|
|
|
return listOperations.rightPush( key, pivot, value);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void set(K key, long index, V value) {
|
|
|
listOperations.set( key, index, value);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public Long remove(K key, long i, Object value) {
|
|
|
return listOperations.remove(key, i, value);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public V index(K key, long index) {
|
|
|
return listOperationsReadOnly.index(key, index);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public V leftPop(K key) {
|
|
|
return listOperations.leftPop(key);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public V leftPop(K key, long timeout, TimeUnit unit) {
|
|
|
return listOperations.leftPop(key, timeout, unit);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public V rightPop(K key) {
|
|
|
return listOperations.rightPop( key);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public V rightPop(K key, long timeout, TimeUnit unit) {
|
|
|
return listOperations.rightPop( key, timeout, unit);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public V rightPopAndLeftPush(K sourceKey, K destinationKey) {
|
|
|
return listOperations.rightPopAndLeftPush( sourceKey, destinationKey);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public V rightPopAndLeftPush(K sourceKey, K destinationKey, long timeout, TimeUnit unit) {
|
|
|
return listOperations.rightPopAndLeftPush( sourceKey, destinationKey, timeout, unit);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public RedisOperations<K, V> getOperations() {
|
|
|
return null;
|
|
|
}
|
|
|
} |
...
|
...
|
|