Created
December 24, 2013 11:30
-
-
Save jwkfreedom/8112000 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.HashMap; | |
import java.util.Map; | |
import redis.clients.jedis.Jedis; | |
public class TestJedis { | |
public static void main(String[] args) { | |
String key = "mostUsedLanguages"; | |
Jedis jedis = new Jedis("localhost"); | |
//Adding a value with score to the set | |
jedis.zadd(key,100,"Java");//ZADD | |
//We could add more than one value in one calling | |
Map<Double, String> scoreMembers = new HashMap<Double, String>(); | |
scoreMembers.put(90d, "Python"); | |
scoreMembers.put(80d, "Javascript"); | |
jedis.zadd(key, scoreMembers); | |
//We could get the score for a member | |
System.out.println("Number of Java users:" + jedis.zscore(key, "Java")); | |
//We could get the number of elements on the set | |
System.out.println("Number of elements:" + jedis.zcard(key));//ZCARD | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment