Skip to content

Instantly share code, notes, and snippets.

@elliottcordo
Created August 8, 2014 11:59
Show Gist options
  • Save elliottcordo/0c600c8a9e58fac1bffa to your computer and use it in GitHub Desktop.
Save elliottcordo/0c600c8a9e58fac1bffa to your computer and use it in GitHub Desktop.
storing and working with timeseries in a redis zset
127.0.0.1:6379> zadd mts-123456 20140302 5.6
(integer) 1
127.0.0.1:6379> zadd mts-123456 20140301 7
(integer) 1
127.0.0.1:6379> zadd mts-123456 20140304 3
(integer) 1
127.0.0.1:6379> zadd mts-123456 20140303 2.7
(integer) 1
127.0.0.1:6379> ZRANGEBYSCORE mts-123456 20140301 20140302
1) "7"
2) "5.6"
127.0.0.1:6379> ZRANGEBYSCORE mts-123456 20140301 20140302 WITHSCORES
1) "7"
2) "20140301"
3) "5.6"
4) "20140302"
127.0.0.1:6379>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment