zoukankan      html  css  js  c++  java
  • 常用API之Set

    public static void main(String[] args) {
            Jedis jedis = new Jedis("127.0.0.1",6379);
            jedis.auth("12345");
            jedis.flushDB();
    
            System.out.println("==================向集合中添加元素(不重复)==================");
            System.out.println(jedis.sadd("eleSet","e1","e2","e3","e4","e5","e6","e7","e8"));
            System.out.println(jedis.sadd("eleSet","e9"));
            System.out.println("eleSet中所有元素为:"+jedis.smembers("eleSet"));
            System.out.println("删除一个元素e1:"+jedis.srem("eleSet","e1"));
            System.out.println("eleSet中所有元素为:"+jedis.smembers("eleSet"));
            System.out.println("随机移除集合中的一个元素:"+jedis.spop("eleSet"));
            System.out.println("随机移除集合中的一个元素:"+jedis.spop("eleSet"));
            System.out.println("eleSet中所有元素为:"+jedis.smembers("eleSet"));
            System.out.println("eleSet中包含元素的个数:"+jedis.scard("eleSet"));
            System.out.println("e3是否在eleSet中:"+ jedis.sismember("eleSet","e3"));
            System.out.println("e2是否在eleSet中:"+ jedis.sismember("eleSet","e2"));
            System.out.println("e9是否在eleSet中:"+ jedis.sismember("eleSet","e9"));
            System.out.println("=============================================");
            System.out.println(jedis.sadd("eleSet1","e1","e2","e3","e4","e5","e6","e7","e8"));
            System.out.println(jedis.sadd("eleSet2","e0","e9","e3","e4","e5"));
            System.out.println("将eleSet1中删除e1并存入eleSet3中:"+jedis.smove("eleSet1","eleSet3","e1"));
            System.out.println("将eleSet1中删除e3并存入eleSet3中:"+jedis.smove("eleSet1","eleSet3","e3"));
            System.out.println("eleSet1中所有元素为:"+jedis.smembers("eleSet1"));
            System.out.println("eleSet3中所有元素为:"+jedis.smembers("eleSet3"));
            System.out.println("========================集合运算=====================");
            System.out.println("eleSet1中的元素:"+jedis.smembers("eleSet1"));
            System.out.println("eleSet2中的元素:"+jedis.smembers("eleSet2"));
            System.out.println("eleSet1和eleSet2的交集:"+jedis.sinter("eleSet1","eleSet2"));
            System.out.println("eleSet1和eleSet2的并集:"+jedis.sunion("eleSet1","eleSet2"));
            System.out.println("eleSet1和eleSet2的差集:"+jedis.sdiff("eleSet1","eleSet2"));
            System.out.println(jedis.sinterstore("eleSet4","eleSet1","eleSet2"));
            System.out.println("eleSet4中的元素:"+jedis.smembers("eleSet4"));
        }
    
  • 相关阅读:
    FFmpeg笔记-基本使用
    记一次下载大文件存在数据异常问题排查
    从零开始编写IntelliJ IDEA插件
    Guava LoadingCache不能缓存null值
    FFmpeg笔记--vcodec和-c:v,-acodec和-c:a的区别?
    说说maven依赖冲突,依赖调解,依赖传递和依赖范围
    记一次NoHttpResponseException问题排查
    JVM源码分析-类加载场景实例分析
    JVM源码分析-JVM源码编译与调试
    理解PHP的变量,值与引用的关系
  • 原文地址:https://www.cnblogs.com/zz-newbie/p/15090866.html
Copyright © 2011-2022 走看看