多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
# 组件源码 /** * <b>方法描述:</b> 删除(单个) <br/> * <b>创建者:</b> admin <br/> * <b>创建时间:</b> 2020-06-09 15:12:34 <br/> * * @param key * 入参|key|{@link java.lang.String} * @param number * 出参|删除的key数量|{@link long} * @return -1 异常<br/> * 1 成功<br/> * 0 失败<br/> */ @Component(label = "删除(单个)", style = "判断型", type = "同步组件", comment = "删除一个Key,如果删除的key不存在,则直接忽略", version = "1.0.0", deprecated = false, author = "admin", date = "2020-06-09 03:12:34") @InParams(param = { @Param(name = "key", comment = "key", type = java.lang.String.class) }) @OutParams(param = { @Param(name = "number", comment = "删除的key数量", type = long.class) }) @Returns(returns = { @Return(id = "-1", desp = "异常"), @Return(id = "1", desp = "成功"), @Return(id = "0", desp = "失败") }) public static ResultBase P_delKey(String key) { try { if (redisTemplate.delete(key)) return ResultBase.newSuccessResult(); } catch (Exception e) { AppLog.error(e); return ResultBase.newExceptionResult("TPTR3016", "删除(单个) 异常:" + AppLog.errorMsg(e)); } return ResultBase.newFailureResult("TPTR3017", "删除redis key 失败"); } 交易中组件使用方式: ![](https://img.kancloud.cn/5a/c0/5ac0c016fd70b1c29e5b2e7b39274cc8_1086x750.jpg) ## 参数说明及示例 key:redis中的key,示例: `"qwer"` 删除的key数量:返回值为数字,记录被删除的key的数量,示例: `__INNER__["num"]` > 删除一个Key,如果删除的key不存在,则直接忽略