Skip to content

Instantly share code, notes, and snippets.

@wataru420
Created March 16, 2012 03:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wataru420/2048302 to your computer and use it in GitHub Desktop.
Save wataru420/2048302 to your computer and use it in GitHub Desktop.
redisTest
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;
redis 127.0.0.1:6379> zscore rank ${userのid}
redis 127.0.0.1:6379> zcount rank (${上で取得したscore} +inf
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