• spring 删除redis


        redisTemplate.execute(new RedisCallback() {
                   public Long doInRedis(RedisConnection connection) throws DataAccessException {
                       long result = 0;
                       result = connection.del(Key.getBytes());
                       return result;
                   }
               });

    //举例

    // 从缓存中取验证码,根据用户名,是否与传入的匹配    

     final String Key = cus.getUsername() + "verificationCode";     

     Object strVerificationCode = redisTemplate.opsForValue().get(Key);    

      if (strVerificationCode == null)// 验证码没取到     {

         message.setCode(ConstantUtil.M_DATA_EXPIRE);     

         message.setMessage("验证码已过期,请重新获取");      

         this.out(response, message);      return;     

      }     

      if (!(strVerificationCode.equals(zipCode))) {     

         message.setCode(ConstantUtil.M_EXCEPTION);     

          message.setMessage("验证码错误");      

          this.out(response, message);     

          return;     

       } else {// 验证通过,删除验证码      

          redisTemplate.execute(new RedisCallback() {               

                  public Long doInRedis(RedisConnection connection) throws DataAccessException {

                       long result = 0;

                       result = connection.del(Key.getBytes());

                       return result;

                   }

               });

        }

  • 相关阅读:
    excel2007灵活计算2个日期之间的工作日
    bat
    eclipse Maven操作出现No compiler is provided in this environment.Perhaps you are running on a JRE rather than a JDK?
    将BeyondCompare设置为TortoiseSVN的扩展比较工具
    python_Excel_xlwt
    Pyqt5_实例1
    Word使用技巧——持续更新
    python_serial
    Pyqt5_Python运用过程中一些问题和技巧
    Pyqt5_QfileDialog
  • 原文地址:https://www.cnblogs.com/cuijinlong/p/6829965.html
Copyright © 2020-2023  润新知