spring-data-redis SetOperations

11 篇文章 0 订阅
8 篇文章 0 订阅

    /**
     * 给集合key添加多个值,集合不存在创建后再添加
     *
     * @param key 不能为null
     * @param values
     * @return
     */
    Long add(K key, V... values);

    /**
     * 移除集合中多个value值
     * @param key 不能为null
     * @param values
     * @return
     */
    Long remove(K key, Object... values);

    /**
     * 随机删除集合中的一个值,并返回。
     *
     * @param key 不能为null
     * @return
     */
    V pop(K key);

    /**
     * 把源集合中的一个元素移动到目标集合。成功返回true.
     *
     * @param key 不能为null
     * @param value
     * @param destKey must not be {@literal null}.
     * @return
     */
    Boolean move(K key, V value, K destKey);

    /**
     * 返回结合的大小
     *
     * @param key 不能为null
     * @return
     * @see <a href="http://redis.io/commands/scard">Redis Documentation: SCARD</a>
     */
    Long size(K key);

    /**
     * 检查集合中是否包含某个元素
     *
     * @param key 不能为null
     * @param o
     * @return
     */
    Boolean isMember(K key, Object o);

    /**
     * 求指定集合与另一个集合的交集
     *
     * @param key 不能为null
     * @param otherKey must not be {@literal null}.
     * @return
     */
    Set<V> intersect(K key, K otherKey);

    /**
     *求指定集合与另外多个个集合交集
     *
     * @param key 不能为null
     * @param otherKeys 不能为null
     * @return
     * @see <a href="http://redis.io/commands/sinter">Redis Documentation: SINTER</a>
     */
    Set<V> intersect(K key, Collection<K> otherKeys);

    /**
     * 求指定集合与另一个集合的交集,并且存储到目标集合中
     *
     * @param key 不能为null
     * @param otherKey 不能为null
     * @param destKey 不能为null
     * @return 返回目标集合的长度
     */
    Long intersectAndStore(K key, K otherKey, K destKey);

    /**
     * 求指定集合与另外多个集合中的交集保存到目标集合
     *
     * @param key 不能为null
     * @param otherKeys 不能为null
     * @param destKey 不能为null
     * @return
     */
    Long intersectAndStore(K key, Collection<K> otherKeys, K destKey);

    /**
     * 求指定集合与另一个集合的并集 并返回并集
     *
     * @param key 不能为null
     * @param otherKey 不能为null
     * @return
     * @see <a href="http://redis.io/commands/sunion">Redis Documentation: SUNION</a>
     */
    Set<V> union(K key, K otherKey);

    /**
     * 求指定集合与另外多个集合的并集 并返回并集
     *
     * @param key 不能为null
     * @param otherKeys 不能为null
     * @return
     * @see <a href="http://redis.io/commands/sunion">Redis Documentation: SUNION</a>
     */
    Set<V> union(K key, Collection<K> otherKeys);

    /**
     *求指定集合与另一个集合的并集,并保存到目标集合
     */
    Long unionAndStore(K key, K otherKey, K destKey);

    /**
     *求指定集合与另外多个集合的并集,并保存到目标集合
     */
    Long unionAndStore(K key, Collection<K> otherKeys, K destKey);

    /**
     * 求指定集合与另一个集合的差集
     */
    Set<V> difference(K key, K otherKey);

    /**
     * 求指定集合与另外多个集合的差集
     */
    Set<V> difference(K key, Collection<K> otherKeys);

    /**
     * 求指定集合与另一个集合的差集,并保存到目标集合
     */
    Long differenceAndStore(K key, K otherKey, K destKey);

    /**
     * 求指定集合与另外多个集合的差集,并保存到目标集合
     */
    Long differenceAndStore(K key, Collection<K> otherKeys, K destKey);

    /**
     * 获取集合中的所有元素
     */
    Set<V> members(K key);

    /**
     * 随机获取集合中的一个元素
     */
    V randomMember(K key);

    /**
     *随机返回集合中指定数量的元素。随机的元素不会重复
     */
    Set<V> distinctRandomMembers(K key, long count);

    /**
     * 随机返回集合中指定数量的元素。随机的元素可能重复
     */
    List<V> randomMembers(K key, long count);

    /**
     * 获取集合的游标。通过游标可以遍历整个集合。
     * ScanOptions 这个类中使用了构造者 工厂方法 单例。 通过它可以配置返回的元素
     * 个数 count  与正则匹配元素 match. 不过count设置后不代表一定返回的就是count个。这个只是参考
     * 意义
     *
     * @param key
     * @param options 
     * @return
     * @since 1.4
     */
    Cursor<V> scan(K key, ScanOptions options);
  • 2
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值