zoukankan      html  css  js  c++  java
  • redis

    一、配置

     <bean id="redisTemplate" class="org.springframework.data.redis.core.RedisTemplate">  
            <property name="connectionFactory" ref="jedisConnectionFactory"></property>  
            <property name="keySerializer">  
                <bean class="org.springframework.data.redis.serializer.StringRedisSerializer"/>  
            </property>  
               <property name="valueSerializer">  
                <bean class="org.springframework.data.redis.serializer.StringRedisSerializer"/>  
            </property>  
        </bean>

    方式一:

    二、插入

    /**
         * 将检验报告存入redis
         * @param response
         * @param key
         */
        private void setRedis(ResponseResult<LisReponse> response,String key,String patientType){
            String redisKey = key;
            String mapKey = key + "-" + patientType + "-"+ (new Date().getTime());
            BoundHashOperations<String, String, Object> boundHashOperations = redisTemplate.boundHashOps(redisKey);  
            Map<String, Object> data = new HashMap<String, Object>(); 
            
            List<LisReponse> list = response.getItems();
            //根据检验日期倒序
            Collections.sort(list,new Comparator<LisReponse>() {
    
                @Override
                public int compare(LisReponse o1, LisReponse o2) {
                    return DateUtil.parseDate(o2.getCheck_time(), "yyyy/MM/dd HH:mm:ss").compareTo(DateUtil.parseDate(o1.getCheck_time(), "yyyy/MM/dd HH:mm:ss"));
                }
                
                
            });
            
            data.put(mapKey, list);
            boundHashOperations.putAll(data);  
        }

    三、获取

        /**
         * 从redis获取结果
         * @param key
         * @return
         */
        private Map<String ,Object> getResultFromRedis(String key){
             BoundHashOperations<String, String, Object> boundHashOperations = redisTemplate.boundHashOps(key);  
             Map<String, Object> data = boundHashOperations.entries();  
             return data;
        }
  • 相关阅读:
    UVA 10600 ACM Contest and Blackout(次小生成树)
    UVA 10369
    UVA Live 6437 Power Plant 最小生成树
    UVA 1151 Buy or Build MST(最小生成树)
    UVA 1395 Slim Span 最小生成树
    POJ 1679 The Unique MST 次小生成树
    POJ 1789 Truck History 最小生成树
    POJ 1258 Agri-Net 最小生成树
    ubuntu 用法
    ubuntu 搭建ftp服务器,可以通过浏览器访问,filezilla上传文件等功能
  • 原文地址:https://www.cnblogs.com/binbang/p/5512387.html
Copyright © 2011-2022 走看看