Note that there are some explanatory texts on larger screens.

plurals
  1. POBest way to approach activity based feeds in asp.net and ravendb
    primarykey
    data
    text
    <p>I will have an activity feed per user that displays all activity related to events the user is subscribed to and the feed will pull in the most current 20 or so activities. The way I have it setup is all activity regardless of the event its related to is stored in one collection and the document itself has an "event" property I query against and index. The basic query is just select activities from collection where event is in the users event subscription list ordered by date. I store a hash of the list of the users event subscriptions and cache the results of the query using the hash as the key for xx seconds so if another user is subscribed to same exact events I can pull the results from cache instead, I'm not concerned with results being xx seconds stale.</p> <p>Edit: added model and query example</p> <p>Models:</p> <pre><code>User { // useless properties excluded // fixed: hashset not list, can be quite large HashSet&lt;string&gt; Subscriptions { get; set; } string SubscriptionHash { get; set; } // precomputed hash of all strings in subscriptions } Activity { // Useless properties excluded string ActivityType { get; set; } } </code></pre> <p>Query:</p> <pre><code>if (cache[user.SubscriptionHash] != null) results = (HashSet&lt;Activity&gt;)cache[user.SubscriptionHash]; else results = session.Query&lt;Activity&gt;().Where(user.Subscriptions.Contains(e =&gt; e.ActivityType)).Take(20).ToList(); // add results to cache </code></pre> <p>My concern is if this is the BEST APPROACH to handle this or if there's better ravendb voodoo to use. The single collection could grow into the millions if there's alot of activities and I could potentially be storing thousands of keys in the cache when there's thousands of users with endless combinations of subscription lists. These feeds are on the users landing page so it gets hit alot and I don't want to just throw more hardware at the problem.</p> <p>So answer im really looking for is if this is the best query to use or if there's a better way to do it in Raven when I could be querying against millions of documents using list.Contains.</p> <p>This is an asp.net 4.5 mvc 4 project using ravendb.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload