SetOperations的Long add(K key, V... values)(Spring模版接口Redis)

文档地址 https://docs.spring.io/spring-data/redis/docs/current/api/org/springframework/data/redis/core/SetOperations.html#add(K,V...)

add

@Nullable
Long add(K key, V... values)

将给定值添加到键处进行设置。
Add given values to set at key.

Parameters:

  • key - must not be null.
  • values -

Returns: null when used in pipeline / transaction.
See Also: Redis Documentation: SADD https://redis.io/docs/latest/commands/sadd/

Redis中的解释

将指定的成员添加到存储在 key 处的集合中。如果指定的成员已经是该集合的成员,则将被忽略。如果 key 不存在,则系统会先创建一个新集合,然后再添加指定的成员。
Add the specified members to the set stored at key. Specified members that are already a member of this set are ignored. If key does not exist, a new set is created before adding the specified members.

如果存储在 key 处的值不是集合,则会返回错误。
An error is returned when the value stored at key is not a set.

posted @ 2025-04-11 20:02  kuki'  阅读(20)  评论(0)    收藏  举报