nisbos


获取集合中元素的数量

<p><strong>简要描述:</strong> </p> <ul> <li>获取集合中元素的数量</li> </ul> <p><strong>入参:</strong> </p> <table> <thead> <tr> <th style="text-align: left;">参数名</th> <th style="text-align: left;">必选</th> <th style="text-align: left;">类型</th> <th>说明</th> </tr> </thead> <tbody> <tr> <td style="text-align: left;">key</td> <td style="text-align: left;">是</td> <td style="text-align: left;">string</td> <td>存储redis中的唯一标识</td> </tr> </tbody> </table> <p><strong>返回示例</strong></p> <pre><code> { 2 }</code></pre> <p><strong>返回参数说明</strong> </p> <table> <thead> <tr> <th style="text-align: left;">参数名</th> <th style="text-align: left;">类型</th> <th>说明</th> </tr> </thead> <tbody> <tr> <td style="text-align: left;">无</td> <td style="text-align: left;">long</td> <td>有序集合的基数</td> </tr> </tbody> </table> <p><strong>示例代码</strong></p> <pre><code class="language-java">IRedisService redisService = ICacheUtil.service(); long lg = redisService.zcard("sortSetTest"); System.out.println("lg:"+lg);</code></pre> <p><strong>接口</strong></p> <pre><code class="language-java">/* * 获取集合中元素的数量 * @param String key * @return 当 key 存在且是有序集类型时,返回有序集的基数。 当 key 不存在时,返回 0 。 */ public long zcard(String key)throws CacheException;</code></pre> <p><strong>备注</strong> </p> <ul> <li>当 key 存在且是有序集类型时,返回有序集的基数。 当 key 不存在时,返回 0</li> </ul>

页面列表

ITEM_HTML