PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Monday, September 5, 2022

[FIXED] How do I get the size of a set on Redis?

 September 05, 2022     redis, set     No comments   

Issue

For lists I can do the operation:

LLEN KeyName

and it will return the size of a list in Redis. What is the equivalent command for sets? I can't seem to find this in any documentation.


Solution

You are looking for the SCARD command:

SCARD key

Returns the set cardinality (number of elements) of the set stored at

Return value
Integer reply: the cardinality (number of elements) of the set, or 0 if key does not exist.

You can view all of the set commands on the documentation webpage.



Answered By - Tim Cooper
Answer Checked By - Pedro (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing