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、相关包下载:百度网盘

  • 相关阅读:
    100-days: twenty-four
    100-days: twenty-three
    100-days: twenty-two
    100-days: twenty-one
    100-days: twenty
    [NOI 2016]循环之美
    [NOI 2015]寿司晚宴
    [BZOJ 2655]calc
    [Codeforces 888G]Xor-MST
    [BZOJ 2839]集合计数
  • 原文地址:https://www.cnblogs.com/sshoub/p/4282795.html
Copyright © 2011-2022 走看看