org.springframework.data.redis.core.BoundListOperations Maven / Gradle / Ivy
/*
* Copyright 2011-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.redis.core;
import java.util.List;
import java.util.concurrent.TimeUnit;
import org.springframework.lang.Nullable;
/**
* List operations bound to a certain key.
*
* @author Costin Leau
* @author Mark Paluch
*/
public interface BoundListOperations extends BoundKeyOperations {
/**
* Get elements between {@code begin} and {@code end} from list at the bound key.
*
* @param start
* @param end
* @return {@literal null} when used in pipeline / transaction.
* @see Redis Documentation: LRANGE
*/
@Nullable
List range(long start, long end);
/**
* Trim list at the bound key to elements between {@code start} and {@code end}.
*
* @param start
* @param end
* @see Redis Documentation: LTRIM
*/
void trim(long start, long end);
/**
* Get the size of list stored at the bound key.
*
* @return {@literal null} when used in pipeline / transaction.
* @see Redis Documentation: LLEN
*/
@Nullable
Long size();
/**
* Prepend {@code value} to the bound key.
*
* @param value
* @return {@literal null} when used in pipeline / transaction.
* @see Redis Documentation: LPUSH
*/
@Nullable
Long leftPush(V value);
/**
* Prepend {@code values} to the bound key.
*
* @param values
* @return {@literal null} when used in pipeline / transaction.
* @see Redis Documentation: LPUSH
*/
@Nullable
Long leftPushAll(V... values);
/**
* Prepend {@code values} to the bound key only if the list exists.
*
* @param value
* @return {@literal null} when used in pipeline / transaction.
* @see Redis Documentation: LPUSHX
*/
@Nullable
Long leftPushIfPresent(V value);
/**
* Prepend {@code values} to the bound key before {@code value}.
*
* @param value
* @return {@literal null} when used in pipeline / transaction.
* @see Redis Documentation: LPUSH
*/
@Nullable
Long leftPush(V pivot, V value);
/**
* Append {@code value} to the bound key.
*
* @param value
* @return {@literal null} when used in pipeline / transaction.
* @see Redis Documentation: RPUSH
*/
@Nullable
Long rightPush(V value);
/**
* Append {@code values} to the bound key.
*
* @param values
* @return {@literal null} when used in pipeline / transaction.
* @see Redis Documentation: RPUSH
*/
@Nullable
Long rightPushAll(V... values);
/**
* Append {@code values} to the bound key only if the list exists.
*
* @param value
* @return {@literal null} when used in pipeline / transaction.
* @see Redis Documentation: RPUSHX
*/
@Nullable
Long rightPushIfPresent(V value);
/**
* Append {@code values} to the bound key before {@code value}.
*
* @param value
* @return {@literal null} when used in pipeline / transaction.
* @see Redis Documentation: RPUSH
*/
@Nullable
Long rightPush(V pivot, V value);
/**
* Set the {@code value} list element at {@code index}.
*
* @param index
* @param value
* @see Redis Documentation: LSET
*/
void set(long index, V value);
/**
* Removes the first {@code count} occurrences of {@code value} from the list stored at the bound key.
*
* @param count
* @param value
* @return {@literal null} when used in pipeline / transaction.
* @see Redis Documentation: LREM
*/
@Nullable
Long remove(long count, Object value);
/**
* Get element at {@code index} form list at the bound key.
*
* @param index
* @return {@literal null} when used in pipeline / transaction.
* @see Redis Documentation: LINDEX
*/
@Nullable
V index(long index);
/**
* Removes and returns first element in list stored at the bound key.
*
* @return {@literal null} when used in pipeline / transaction.
* @see Redis Documentation: LPOP
*/
@Nullable
V leftPop();
/**
* Removes and returns first element from lists stored at the bound key .
* Blocks connection until element available or {@code timeout} reached.
*
* @param timeout
* @param unit must not be {@literal null}.
* @return {@literal null} when timeout reached or used in pipeline / transaction.
* @see Redis Documentation: BLPOP
*/
@Nullable
V leftPop(long timeout, TimeUnit unit);
/**
* Removes and returns last element in list stored at the bound key.
*
* @return {@literal null} when used in pipeline / transaction.
* @see Redis Documentation: RPOP
*/
@Nullable
V rightPop();
/**
* Removes and returns last element from lists stored at the bound key.
* Blocks connection until element available or {@code timeout} reached.
*
* @param timeout
* @param unit must not be {@literal null}.
* @return {@literal null} when timeout reached or used in pipeline / transaction.
* @see Redis Documentation: BRPOP
*/
@Nullable
V rightPop(long timeout, TimeUnit unit);
RedisOperations getOperations();
}