zoukankan      html  css  js  c++  java
  • redis使用

    1、服务器

    下载redis Windows版,命令行启动redis-server.exe即可。

    2、客户端使用 jedis

    添加DLL:

    commons-pool2-2.0.jar

    jedis-2.4.2.jar

    3、源码示例:

    package nankang.test;
    
    import redis.clients.jedis.Jedis;
    import redis.clients.jedis.JedisPool;
    import redis.clients.jedis.JedisPoolConfig;
    
    
    public class Main {
    
        /**
         * @param args
         */
        public static void main(String[] args) {
            // TODO Auto-generated method stub
            try {
                
                JedisPoolConfig config = new JedisPoolConfig();
                JedisPool pool = new JedisPool(config, "127.0.0.1");
                
                Jedis jedis = pool.getResource();
                
                jedis.set("name", "sun shoubin");
                System.out.println(jedis.get("name"));
                
                jedis.append("name", "sun shoubin2");
                System.out.println(jedis.get("name"));
                
                jedis.set("name", "sun shoubin3");
                System.out.println(jedis.get("name"));
                
                jedis.del("name");
                System.out.println(jedis.get("name"));
                
                System.out.println("导出成功");
            } catch (Exception e) {
                System.out.println(String.format("导出失败,%s", e.getMessage()));
            }
    
            System.exit(0);
        }
    
    }


    4、相关包下载:百度网盘

  • 相关阅读:
    【设计模式】——抽象工厂模式
    【设计模式】——观察者模式
    Candy
    Two Sum
    Interleaving String
    Longest Valid Parentheses
    【设计模式】——建造者模式
    【设计模式】——外观模式
    Simplify Path
    Word Search
  • 原文地址:https://www.cnblogs.com/sshoub/p/4282795.html
Copyright © 2011-2022 走看看