• 常用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"));
        }
    
  • 相关阅读:
    latex如何输入正确的 双引号
    【leetcode】Linked List Cycle
    CodeForces 441 A. Valera and Antique Items
    JS封深入了解
    ArcGIS Engine开发之旅04---ARCGIS接口详细说明
    ArcGIS Engine开发之旅03--ArcGIS Engine中的控件
    ArcGIS Engine开发之旅02--ArcGIS Engine中的类库
    ArcGIS Engine开发之旅01---产品组成、逻辑体系结构
    ArcGIS三大文件格式解析
    1.准备工作及实例
  • 原文地址:https://www.cnblogs.com/zz-newbie/p/15090866.html
Copyright © 2020-2023  润新知