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

    public static void main(String[] args) {
            Jedis jedis = new Jedis("127.0.0.1",6379);
            jedis.auth("12345");
            jedis.flushDB();
    
            System.out.println("==================添加一个List==================");
            System.out.println(jedis.lpush("collections","ArrayList","Vector","Stack","HashMap","WeakHashMap","LinkedHashMap"));
            System.out.println(jedis.lpush("collections","HashSet"));
            System.out.println(jedis.lpush("collections","TreeSet"));
            System.out.println(jedis.lpush("collections","TreeMap"));
            System.out.println("collections的内容:"+jedis.lrange("collections",0,-1));
            System.out.println("collections区间0-3的元素:"+jedis.lrange("collections",0,3));
    
            System.out.println("=============================================");
            //删除列表指定的值,第二个参数为删除的个数(有重复时),后add进去的值先被删,类似于出栈
            System.out.println("删除指定元素个数:"+jedis.lrem("collections",2,"HashMap"));
            System.out.println("collections的内容:"+jedis.lrange("collections",0,-1));
            System.out.println("删除下表0-3区间之外的元素:"+jedis.ltrim("collections",0,3));
            System.out.println("collections的内容:"+jedis.lrange("collections",0,-1));
            System.out.println("collections列表出栈(左端):"+jedis.lpop("collections"));
            System.out.println("collections的内容:"+jedis.lrange("collections",0,-1));
            System.out.println("collections添加元素,从列表右端,与lpush相对应:"+jedis.rpush("collections","EnumMap"));
            System.out.println("collections的内容:"+jedis.lrange("collections",0,-1));
            System.out.println("collections列表出栈(右端):"+jedis.rpop("collections"));
            System.out.println("collections的内容:"+jedis.lrange("collections",0,-1));
            System.out.println("修改collections指定下标1的内容:"+jedis.lset("collections",1,"LinkedArrayList"));
            System.out.println("collections的内容:"+jedis.lrange("collections",0,-1));
            System.out.println("=============================================");
            System.out.println("collections长度:"+jedis.llen("collections"));
            System.out.println("获取collections下标为2的元素:"+jedis.lindex("collections",2));
            System.out.println("=============================================");
            System.out.println(jedis.lpush("sortedList","2","3","5","0","9","1"));
            System.out.println("sortedList排序前:"+jedis.lrange("sortedList",0,-1));
            System.out.println(jedis.sort("sortedList"));
            System.out.println("sortedList排序后:"+jedis.lrange("sortedList",0,-1));
    
        }
    
  • 相关阅读:
    Windows Server 2012 R2 密钥
    C# 将List转成树的两种方式(递归、循环)
    C# 实现PPT、Word、Excel文件转为图片
    Net JavaScript:跨域问题(No 'Access-Control-Allow-Origin')
    IIS WebApi: 文件上传,大小限制,提示413 (Request Entity Too Large)
    layui动态表格数据选择添加穿梭框代码
    MySQL + Keepalived 双主热备高可用解决方案
    PHP高并发问题处理思路
    xhprof性能分析工具安装与使用
    uni-app在小程序中v-show指令失效
  • 原文地址:https://www.cnblogs.com/zz-newbie/p/15090873.html
Copyright © 2011-2022 走看看