0

use a sortedset to store a user's events :

zrangebyscore Fred -inf +inf withscores
1) "SEQNO20180607001"  [event's unique id]
2) "1514736000000"   [event's time, a unix timestamp]
3) "SEQNO20180607002"
4) "1514736000230"
5) "SEQNO20180607003"
6) "15147360002235"

and a simple key-value pair to store the event's details:

get SEQNO20180607001
"{\"name\":\"Fred\",\"age\":25,\"action\":\"click main page\"}"

like this question, the event detail, its value length isn't predictable, so I think 'hash' is not a good choice and I'm thinking about the sortedset's memory usage.Is there a good way to minimize the sortedset's memory usage? Thanks.

bylijinnan
  • 756
  • 3
  • 11
  • 27
  • Do you realy need to store the timesamp? Can you use a simpe list and push event instead? Add timestamp in your json value if needed – khanou Jun 07 '18 at 13:38
  • with one list of events per user you will get the data in only one place – khanou Jun 07 '18 at 13:46
  • I need to get a user's events in a specific time range very quickly(like 'select ... where user=Fred and time between xxx and yyy'), so I think I have to store the timestamp – bylijinnan Jun 08 '18 at 06:23

0 Answers0