Skip to content

Commit

Permalink
Update README with very basic intro.
Browse files Browse the repository at this point in the history
  • Loading branch information
bretthoerner committed Aug 8, 2011
1 parent 285bce1 commit d887164
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions README.rst
@@ -1 +1,43 @@
timak
=====

timak is a Python library for storing timelines (activity streams) in Riak. It is very alpha and rough around the edges.

Example
-------

Timelines are unique sets of objects (unique by the ID you provide) ordered by a datetime (that you also provide). They are bounded, so items fall of the end when a (user defined) capacity is reached.

>>> from datetime import datetime
>>> import riak
>>> from timak.timelines import Timeline

>>> conn = riak.RiakClient()

>>> tl = Timeline(connection=conn, max_items=3)

>>> tl.add("brett:tweets", 1, datetime(2011, 1, 1))
[1]
>>> tl.add("brett:tweets", 2, datetime(2011, 1, 2))
[2, 1]
>>> tl.add("brett:tweets", 3, datetime(2011, 1, 3))
[3, 2, 1]
>>> tl.add("brett:tweets", 4, datetime(2011, 1, 4))
[4, 3, 2]
>>> tl.delete("brett:tweets", 2, datetime(2011, 1, 2))
[4, 3]

As you can see the default order is descending by the date you provide, and the object IDs are returned by default. You can also provide an ``obj_data`` argument (JSON serializable) which will be returned instead.

>>> tl.add("brett:tweets", 5, datetime(2011, 1, 5), obj_data={'body': 'Hello world, this is my first tweet'})
[{'body': 'Hello world, this is my first tweet'}, 4, 3]


TODO
----

1. Explain why this is special.
2. Go into drawbacks.
3. Add better API with cursors (last seen obj_date?) for pagination.
4. Built-in Django support for update on ``post_save`` and ``post_delete``.
5. Tests, tests, tests.

0 comments on commit d887164

Please sign in to comment.