zoukankan      html  css  js  c++  java
  • redis测试

    1,安装redis软件

    2,引入redis jar包

    3,案例

    package test;
    
    import java.util.List;
    
    import redis.clients.jedis.Jedis;
    
    public class RedTest {
    
        /**
         * @param args
         */
        public static void main(String[] args) {
            /*// TODO Auto-generated method stub
            //连接本地的 Redis 服务
              Jedis jedis = new Jedis("localhost");
              System.out.println("Connection to server sucessfully");
              //查看服务是否运行
              System.out.println("Server is running: "+jedis.ping());
              
            //设置 redis 字符串数据
              jedis.set("w3ckey", "Redis tutorial");
             // 获取存储的数据并输出
             System.out.println("Stored string in redis:: "+ jedis.get("w3ckey"));
             
             System.out.println("---------------------------------");
             //存储数据到列表中
              jedis.lpush("tutorial-list", "Redis");
              jedis.lpush("tutorial-list", "Mongodb");
              jedis.lpush("tutorial-list", "Mysql");
             // 获取存储的数据并输出
             List<String> list = jedis.lrange("tutorial-list", 0 ,5);
             for(int i=0; i<list.size(); i++) {
               System.out.println("Stored string in redis:: "+list.get(i));
             }
             */
             System.out.println("--------------------------------");
           //连接本地的 Redis 服务
              Jedis jedis = new Jedis("localhost");
              System.out.println("Connection to server sucessfully");
             // 获取数据并输出
             List<String> list1 = (List<String>) jedis.keys("*");
             for(int i=0; i<list1.size(); i++) {
               System.out.println("List of stored keys:: "+list1.get(i));
             }
           
              
        }
    
    }
    好记性不如烂笔头
  • 相关阅读:
    translations.dart阅读
    # objc-weak 阅读
    Objective-C Runtime2.0(-)
    iOS图文混排
    BestCoder Round #85 抽屉原理/贪心/质因数
    hdu 5763 Another Meaning KMP+DP(多校)
    hdu 5775 Bubble Sort 树状数组(多校)
    BestCoder Round #84
    hdu 5724 SG函数+状压(多校)
    hdu 5723 最小生成树+dfs (多校)
  • 原文地址:https://www.cnblogs.com/codehello/p/10841459.html
Copyright © 2011-2022 走看看