Permalink
Browse files

Test multiple writers.

  • Loading branch information...
1 parent fa0100a commit ec99768ff13bca69dc47c44ec57df6d14bdc74e0 @bretthoerner committed Aug 9, 2011
Showing with 15 additions and 5 deletions.
  1. +3 −4 README.rst
  2. +12 −1 tests/tests.py
View
7 README.rst
@@ -38,7 +38,7 @@ As you can see the default order is descending by the date you provide, and the
Why?
----
-I needed *highly available*, *linearly scalable* timelines where readers and writers *don't block* one another. Because Riak is a Dynamo system, multiple writers can update a single value and I can merge the conflicts on a later read. I can also add a machine to the cluster for more throughput, and since it's simply fetching denormalized timelines by key it should be incredibly performant.
+I needed *highly available*, *linearly scalable* timelines where readers and writers *don't block* one another. Because Riak is a Dynamo based system, multiple writers can update a single value and I can merge the conflicts on a later read. I can also add a machine to the cluster for more throughput, and since it's simply fetching denormalized timelines by key it should be incredibly performant.
So what? I could write this in...
---------------------------------
@@ -61,14 +61,13 @@ You can fake timelines in Redis using a list or sorted set. Like RDBMS you have
Cassandra
`````````
-Probably another great fit. You could even store much longer timelines, though I'm not sure what the cost is of going an ORDER_BY/OFFSET equivalent on the columns in a Cassandra row.
+Probably another great fit. You could even store much longer timelines, though I'm not sure what the cost is of doing an ORDER_BY/OFFSET equivalent on the columns in a Cassandra row.
TODO
----
1. Add better API with cursors (last seen ``obj_date``?) for pagination.
2. Built-in Django support for update on ``post_save`` and ``post_delete``.
-3. Tests, tests, tests.
-4. Compress values.
+3. Compress values.
View
13 tests/tests.py
@@ -1,4 +1,4 @@
-from datetime import datetime
+from datetime import datetime, timedelta
import unittest2
import riak
@@ -60,3 +60,14 @@ def test_delete(self):
timeline.delete(self.key, 1, now)
self.assertEqual(len(timeline.get(self.key)), 0)
+
+ def test_multi_writers(self):
+ now = datetime.utcnow()
+
+ t1 = Timeline(connection=self.c1, bucket=self.bucket, max_items=10)
+ t2 = Timeline(connection=self.c2, bucket=self.bucket, max_items=10)
+
+ t1.add(self.key, 1, now)
+ t2.add(self.key, 2, now + timedelta(minutes=1))
+
+ self.assertEqual(t1.get(self.key), [2, 1])

0 comments on commit ec99768

Please sign in to comment.