Created
March 16, 2012 03:08
-
-
Save wataru420/2048302 to your computer and use it in GitHub Desktop.
redisTest
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
drop table if exists ranking; | |
create table ranking( | |
id VARCHAR(12) NOT NULL PRIMARY KEY, | |
point BIGINT NOT NULL, | |
INDEX USING HASH (point) | |
) ENGINE=MEMORY; |
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
redis 127.0.0.1:6379> zscore rank ${userのid} | |
redis 127.0.0.1:6379> zcount rank (${上で取得したscore} +inf |
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
SELECT count(id)+1 FROM ranking WHERE point < (SELECT point FROM ranking WHERE id=${userのid}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment