Implements a powerful analytics library using Redis bitmaps.
Project description
bitmapist
Implements a powerful analytics library using Redis bitmaps.
This library makes it possible to implement real-time, highly scalable analytics that can answer following questions:
Has user 123 been online today? This week? This month?
Has user 123 performed action “X”?
How many users have been active have this month? This hour?
How many unique users have performed action “X” this week?
How many % of users that were active last week are still active?
How many % of users that were active last month are still active this month?
This library is very easy to use and enables you to create your own reports easily.
Using Redis bitmaps you can store events for millions of users in a very little amount of memory (megabytes). You should be careful about using huge ids (e.g. 2^32 or bigger) as this could require larger amounts of memory.
If you want to read more about bitmaps please read following:
http://blog.getspool.com/2011/11/29/fast-easy-realtime-metrics-using-redis-bitmaps/
http://www.slideshare.net/crashlytics/crashlytics-on-redis-analytics
http://amix.dk/blog/post/19714 [my blog post]
Requires Redis 2.6+ and newest version of redis-py.
Examples
Setting things up:
from datetime import datetime, timedelta from bitmapist import setup_redis, delete_all_events, mark_event, MonthEvents, WeekEvents, DayEvents, HourEvents, BitOpAnd, BitOpOr now = datetime.utcnow() last_month = datetime.utcnow() - timedelta(days=30)
Mark user 123 as active and has played a song:
mark_event('active', 123) mark_event('song:played', 123)
Answer if user 123 has been active this month:
assert 123 in MonthEvents('active', now.year, now.month) assert 123 in MonthEvents('song:played', now.year, now.month)
How many users have been active this week?:
print len(WeekEvents('active', now.year, now.isocalendar()[1]))
Perform bit operations. How many users that have been active last month are still active this month?:
active_2_months = BitOpAnd( MonthEvents('active', last_month.year, last_month.month), MonthEvents('active', now.year, now.month) ) print len(active_2_months) # Is 123 active for 2 months? assert 123 in active_2_months
Work with nested bit operations (imagine what you can do with this ;-)):
active_2_months = BitOpAnd( BitOpAnd( MonthEvents('active', last_month.year, last_month.month), MonthEvents('active', now.year, now.month) ), MonthEvents('active', now.year, now.month) ) print len(active_2_months) assert 123 in active_2_months
Copyright: 2012 by Doist Ltd.
Developer: Amir Salihefendic ( http://amix.dk )
License: BSD
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file bitmapist-1.5.tar.gz
.
File metadata
- Download URL: bitmapist-1.5.tar.gz
- Upload date:
- Size: 5.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 85869ddfd97960325406953ac1eda9d650394e94f3191d5e0af7b7c34b30a603 |
|
MD5 | 36df3cd44d00f36e6620b57e883ed4dc |
|
BLAKE2b-256 | 03e9a1dcd7862e1fb0d5d7407529d316cdaf7f65d45a4b2521d7a1f4b61d7a39 |
Provenance
File details
Details for the file bitmapist-1.5-py2.7.egg
.
File metadata
- Download URL: bitmapist-1.5-py2.7.egg
- Upload date:
- Size: 14.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c860269c2e18c0d5651918a77cfd268c9cba5eda6a852cf91dd68e1f9a8b0e13 |
|
MD5 | 2dd83e771adea89d94035b046971b6fe |
|
BLAKE2b-256 | 60a491413321455d37866ae13160913bcb61ba28ce05b00d195ace91a018edb3 |