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

    public static void main(String[] args) {
            Jedis jedis = new Jedis("127.0.0.1",6379);
            jedis.auth("12345");
    
            System.out.println("清空数据:"+jedis.flushDB());
            System.out.println("判断某个键是否存在:"+jedis.exists("username"));
            System.out.println("新增<'username','kuangsheng'>的键值对:"+jedis.set("username","kuangsheng"));
            System.out.println("新增<'password','password'>的键值对:"+jedis.set("password","password"));
            System.out.println("系统中所有的键如下:");
            Set<String> keys = jedis.keys("*");
            System.out.println(keys);
            System.out.println("删除键password:"+jedis.del("password"));
            System.out.println("判断键password是否存在:"+jedis.exists("password"));
            System.out.println("查看键username所存储的值的类型:"+jedis.type("username"));
            System.out.println("随机返回key空间的一个:"+jedis.randomKey());
            System.out.println("重命名key:"+jedis.rename("username","name"));
            System.out.println("取出改后的name:"+jedis.get("name"));
            System.out.println("按索引查询:"+jedis.select(0));
            System.out.println("删除当前选择数据库中的所有key:"+jedis.flushDB());
            System.out.println("返回当前数据库中key的数目:"+jedis.dbSize());
            System.out.println("删除所有数据库中的所有key:"+jedis.flushAll());
    
        }
    

     

  • 相关阅读:
    PAT 天梯赛 L1-002 【递归】
    HDU_2717_Catch That Cow
    Stock Exchange (最大上升子子串)
    Lorenzo Von Matterhorn(map的用法)
    Ignatius and the Princess IV (简单DP,排序)
    投掷硬币(概率dp)
    Find The Multiple (DFS递归)
    24 Game
    棋盘问题
    linux上的文件服务
  • 原文地址:https://www.cnblogs.com/zz-newbie/p/15090891.html
Copyright © 2011-2022 走看看