Last active
December 20, 2015 19:09
-
-
Save prisoner/6180999 to your computer and use it in GitHub Desktop.
Fast, easy, realtime metrics using Redis bitmaps
This file contains hidden or 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 redis.clients.jedis.Jedis; | |
import java.util.BitSet; | |
Jedis redis = new Jedis("localhost"); | |
public int uniqueCount(String action, String date) { | |
String key = action + ":" + date; | |
BitSet users = BitSet.valueOf(redis.get(key.getBytes())); | |
return users.cardinality(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment