多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
# 组件源码 /** * <b>方法描述:</b> 集合元素数量 <br/> * <b>创建者:</b> admin <br/> * <b>创建时间:</b> 2018-05-09 10:38:54 <br/> * * @param key * 入参|key|{@link java.lang.String} * @param length * 出参|值|{@link long} * @return -1 异常<br/> * 1 成功<br/> */ @Component(label = "集合元素数量", style = "判断型", type = "同步组件", comment = "集合的元素的数量,如果key不存在,则返回 0", version = "1.0.0", deprecated = false, author = "admin", date = "2018-05-09 10:38:54") @InParams(param = { @Param(name = "key", comment = "key", type = java.lang.String.class) }) @OutParams(param = { @Param(name = "length", comment = "值", type = long.class) }) @Returns(returns = { @Return(id = "-1", desp = "异常"), @Return(id = "1", desp = "成功") }) public static ResultBase P_scard(String key) { try { long obj = redisTemplate.opsForSet().size(key); return ResultBase.newSuccessResult(obj); } catch (Exception e) { AppLog.error(e); return ResultBase.newExceptionResult("TPTR4006", "key对应的数据结构不是Set类型"); } } 交易中组件使用方式: ![](https://img.kancloud.cn/6e/7d/6e7d09047c43053696d478660e0c76c3_950x750.jpg) ## 参数说明及示例 key:redis中的key,示例: `"qwer"` 值:返回集合中元素size的值,示例: `__INNER__["result"]` > 集合的元素的数量,如果key不存在,则返回 0