Giter VIP home page Giter VIP logo

redis-moment's Introduction

redis-moment

A powerful analytics python library for Redis.

Installation

The easiest way to install the latest version is by using pip/easy_install to pull it from PyPI:

pip install redis-moment

You may also use Git to clone the repository from Github and install it manually:

git clone https://github.com/caxap/redis-moment.git
python setup.py install

Features

  1. Advanced data structures optimized for event crunching:
  • Events (Cohort analytics)
  • Counters
  • Timelines
  • Time Indexed Keys
  • Sequences
  1. Partitioning by hour, day, week, month and year.
  2. Pluggable serialization (default: json, pickle, msgpack)
  3. Multiple Redis connections (with aliasing)
  4. Key namespacing
  5. Local caching (LRU lib requred)
  6. Integration with Django

Connections

from moment import conf

# Register default connection 
conf.register_connection()

# Register some other connection
conf.register_connection(alias='analytics', host='localhost', port=6379)

analytics_conn = conf.get_connection('analytics')

Sequence

Use Sequence to convert symbolic identifier to sequential ids. Event component uses Sequence under the hood. Also Sequence optionaly holds cache of recenly created ids.

from moment import Sequence 

users = Sequence('users')
id1 = seq.sequential_id('user1')
id_one = seq.sequential_id('user1')  # will not create new id, and return already assigned value
id2 = seq.sequential_id('user2')
    
assert id1 == 1
assert id1 == id_one
assert id2 == 2
assert 'user1' in users and 'user2' in users

Events

Events makes it possible to implement real-time, highly scalable analytics that can track actions for millions of users in a very little amount of memory. With events you can track active users, user retension, user churn, CTR of user actions and more. You can track events per hour, day, week, month and year.

from moment import record_events, DayEvent, MonthEvent

# We whant to track active users by day and month. Mark `user1` & `user2` as active. 
record_events(['user1', 'user2'], 'users:active', ['day', 'month'], sequence='users')


# Has `user1` been online today? This month?
active_today = DayEvent('users:active',  sequence='users')
active_this_month = MonthEvent('users:active',  sequence='users')

assert 'user1' in active_today, 'should be active today'
assert 'user1' in active_this_month, 'should be active this month'


# Track some events:
record_events('user1', ['event1', 'event2'], ['day', 'month'], sequence='users')
record_events('user2', ['event2', 'event3'], ['day', 'month'], sequence='users')

# Inspect recorded events for today
e1 = DayEvent('event1', sequence='users')
e2 = DayEvent('event2', sequence='users')

assert len(e1) == 1
assert len(e2) == 2
assert 'user1' in e1 and 'user1' in e2
assert 'user2' in e2
assert len(e1 & e2) == 1
assert len(e1 - e2) == 0

More docs comming soon...

redis-moment's People

Contributors

caxap avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

lordi

redis-moment's Issues

Is it possible to have BaseSecond?

Hello,

I need to monitor which python server is online, I can send packages from those servers to redis like a heartbeat (pinging) but I can't filter in a BaseDay interval, when a server stop working it should me removed from the monitoring system asap.

It is a realtime distributed scrapy monitor, made with React:
server

redis-moment can help me? Thank you

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.