/** * 获取上传地址,每次调用缓存延长24小时 * * @param uuid * @return * @throws IOException */ public static String getUploadFilePath(String uuid) { Jedis jedis = getJedis(); Response<String> pathResponse; try { String key = CacheConstants.Redis_String_PhotoPath + uuid; // if(true)return jedis.get(key); Pipeline p = jedis.pipelined(); pathResponse = p.get(key); p.expire(key, CacheConstants.Redis_String_PhotoPath_Expire); p.sync(); p.close(); // List<Object> results = p.syncAndReturnAll(); String path = pathResponse.get(); if (path != null) return path; List list = nSimpleHibernateDao .createSqlQuery("select path from fp_photo_item where uuid='" + uuid + "'") .list(); if (list != null && list.size() > 0) { path = (String) list.get(0); setUploadFilePath(uuid, path); } else { // 防止暴力查数据库 setUploadFilePath(uuid, ""); } return path; } catch (Exception e) { //// e.printStackTrace(); throw e; } finally { if (jedis != null) jedis.close(); } }