org.springframework.data.redis.core.SetOperations Maven / Gradle / Ivy
/*
* Copyright 2011-2022 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
*
* https://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.Collection;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.springframework.lang.Nullable;
/**
* Redis set specific operations.
*
* @author Costin Leau
* @author Christoph Strobl
* @author Mark Paluch
* @author Roman Bezpalko
*/
public interface SetOperations {
/**
* Add given {@code values} to set at {@code key}.
*
* @param key must not be {@literal null}.
* @param values
* @return {@literal null} when used in pipeline / transaction.
* @see Redis Documentation: SADD
*/
@Nullable
Long add(K key, V... values);
/**
* Remove given {@code values} from set at {@code key} and return the number of removed elements.
*
* @param key must not be {@literal null}.
* @param values
* @return {@literal null} when used in pipeline / transaction.
* @see Redis Documentation: SREM
*/
@Nullable
Long remove(K key, Object... values);
/**
* Remove and return a random member from set at {@code key}.
*
* @param key must not be {@literal null}.
* @return {@literal null} when used in pipeline / transaction.
* @see Redis Documentation: SPOP
*/
@Nullable
V pop(K key);
/**
* Remove and return {@code count} random members from set at {@code key}.
*
* @param key must not be {@literal null}.
* @param count number of random members to pop from the set.
* @return {@literal null} when used in pipeline / transaction.
* @see Redis Documentation: SPOP
* @since 2.0
*/
@Nullable
List pop(K key, long count);
/**
* Move {@code value} from {@code key} to {@code destKey}
*
* @param key must not be {@literal null}.
* @param value
* @param destKey must not be {@literal null}.
* @return {@literal null} when used in pipeline / transaction.
* @see Redis Documentation: SMOVE
*/
@Nullable
Boolean move(K key, V value, K destKey);
/**
* Get size of set at {@code key}.
*
* @param key must not be {@literal null}.
* @return {@literal null} when used in pipeline / transaction.
* @see Redis Documentation: SCARD
*/
@Nullable
Long size(K key);
/**
* Check if set at {@code key} contains {@code value}.
*
* @param key must not be {@literal null}.
* @param o
* @return {@literal null} when used in pipeline / transaction.
* @see Redis Documentation: SISMEMBER
*/
@Nullable
Boolean isMember(K key, Object o);
/**
* Check if set at {@code key} contains one or more {@code values}.
*
* @param key must not be {@literal null}.
* @param objects
* @return {@literal null} when used in pipeline / transaction.
* @since 2.6
* @see Redis Documentation: SMISMEMBER
*/
@Nullable
Map