💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
# 组件源码 /** * <b>方法描述:</b> key是否存在 <br/> * <b>创建者:</b> admin <br/> * <b>创建时间:</b> 2018-05-09 10:32:43 <br/> * * @param key * 入参|key值|{@link java.lang.String} * @return -1 异常<br/> * 0 失败<br/> * 1 成功<br/> */ @Component(label = "key是否存在", style = "判断型", type = "同步组件", comment = "判断redis是否存在key", version = "1.0.0", deprecated = false, author = "admin", date = "2018-05-09 10:32:43") @InParams(param = { @Param(name = "key", comment = "key值", type = java.lang.String.class) }) @Returns(returns = { @Return(id = "-1", desp = "异常"), @Return(id = "0", desp = "失败"), @Return(id = "1", desp = "成功") }) public static ResultBase P_exists(String key) { try { if (redisTemplate.hasKey(key)) return ResultBase.newSuccessResult(); return ResultBase.newFailureResult("TPTR3006", "key不存在"); } catch (Exception e) { AppLog.error(e); return ResultBase.newExceptionResult("TPTR3005", "key是否存在 异常:" + AppLog.errorMsg(e)); } } 交易中组件使用方式: ![](https://img.kancloud.cn/6f/f1/6ff117be0ca0ec2150a32986c03608e2_1109x1163.jpg) ## 参数说明及示例 key值:redis中的key,示例: `"oldKey"` > 判断redis是否存在key