81,092
社区成员
发帖
与我相关
我的任务
分享
public String deleteFile(OssTools.Bucket bucket, String key) {
OSSClient ossClient = AliyunOSSClient.getOSSClient();
ResultJson resultJson = new ResultJson();
try {
ossClient.deleteObject(bucket.getName(), key);
Thread.sleep(100);
RedisClient.lrem(bucket.getBasePath(),1L,"http://" + bucket.getName() + "." + AliyunOSSClient.getDefaultDomain() + "/" + key);
resultJson.setSuccess(true);
} catch (OSSException oe) {
resultJson.setSuccess(false);
resultJson.setErrorCode(oe.getErrorCode());
resultJson.setErrorMessage(oe.getErrorMessage());
resultJson.setErrorType("OSSException");
} catch (ClientException ce) {
resultJson.setSuccess(false);
resultJson.setErrorType("ClientException");
resultJson.setErrorMessage(ce.getErrorMessage());
} catch (Exception e) {
resultJson.setSuccess(false);
resultJson.setErrorMessage(e.getMessage());
}
return JSONObject.fromObject(resultJson).toString();
}
public static Long lrem(String key, Long count, String value) {
Jedis jedis = jedisPool.getResource();
Long result = jedis.lrem(key, count, value);
jedis.close();
return result;
}
redis操作是去连接redis数据库,删除文件操作是通过http调用阿里云的云服务接口,我想不到有什么冲突的地方,另外冲突了不会抛异常么? 既然加上Thread.sleep(100);这个可以删除。你就应该考虑到线程的问题。很明显两个操作启动一个或俩个都单独启用了一个线程。然后这三个或者两个线程某些地方冲突了。导致无法删除
既然加上Thread.sleep(100);这个可以删除。你就应该考虑到线程的问题。很明显两个操作启动一个或俩个都单独启用了一个线程。然后这三个或者两个线程某些地方冲突了。导致无法删除
[quote=引用 2 楼 donghc1993 的回复:] [quote=引用 1 楼 u011594442 的回复:] 那你redis的执行正常吗?
[quote=引用 1 楼 u011594442 的回复:] 那你redis的执行正常吗?
那你redis的执行正常吗?