My 2c:

1000s of subscribers per list isn't a problem. Just have a data object which 
represents the subscriber list, store a list of subscriber ids in the 
subscriber list object. Load the whole list every time, and sort/paginate in 
your app code.

Unless you're planning on shuffling the lists a lot, that will be the most 
direct way to implement it. 

Caveats:
Unless you're planning on running into the object size limit with subscriber 
ids or planning on being able to handle thousands of simultaneous subscriptions 
to the same list, but don't want to handle conflict resolution.

My solution:
I ran into this same problem with my app, but with hundreds of thousands to 
millions of uuids per list. I tried a couple of Riak based solutions with 
different data formats, but I wasn't really satisfied with any of them. I ended 
up just having a uuid to uuid lookup table in a postgres database to handle 
internal item to item relations using the uuid datatype for efficient indexing.

I'm not sure if there are any good support libraries for handling polyglot 
consistency in ruby, or if you could blend database ActiveRecord and ripple 
models in the same app (I mean, you probably can, right? You'd just have 
objects inherit from different base classes? There are probably some unhandled 
relation-chaining edge cases though... although ActiveRecord can be magic 
sometimes.)

- Alex 

----- Original Message -----
From: "Martin Stabenfeldt" <mar...@stabenfeldt.net>
To: riak-users@lists.basho.com
Sent: Wednesday, July 18, 2012 2:54:35 AM
Subject: Pagination with Ripple


Dear List, 


I´m planning to use Riak as my primary DB for my Rails app. 


The first issue I´ve encountered is pagination. 


I got a SubscriberList which may contain 1000´s of Subscribers. Any suggestion 
on how I can implement pagination? My plan was to use will_paginate . 








class Subscriber 
include Ripple :: Document 


# Belongs to a SubscriberList 
one :subscriber_list 
property :subscriber_list_key , String 
property :email , String 
property :referer , String 
timestamps! 


validates_presence_of :email 
end 






class SubscriberList 
include Ripple :: Document 
one :user 
property :user_key , String 


# Has_many Subscribers 
many :subscribers , :using => :reference 
# Used by User to find which SubscriberList he has 
property :subscriber_key , String 
property :title , String 
property :deleted , Boolean 
timestamps! 


validates_presence_of :user 
end 


-- 
Martin Stabenfeldt 
Tlf: +47 93441707 

_______________________________________________
riak-users mailing list
riak-users@lists.basho.com
http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com

_______________________________________________
riak-users mailing list
riak-users@lists.basho.com
http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com

Reply via email to