views:

308

answers:

2

Having a project with following requirements in mind.

  • data reading intensive application.
  • 100 max concurrent users a times. Application have very high
  • Though data is huge it is getting modified only once a day

Decided to use subsonic cause of ease of development and potential to work in high traffic environment.

Though few things are not yet found/solved to work with SubSonic 3

  • Which type of layer to use Active Records, Repository, Linq To SQL
  • working with paging / sorting stored procedures (cause they will give better performance over inbuilt paging mechanism, when displaying 10000+ rows with paging and sorting. right?? )
  • Caching, with project requirement it is quite clear, heavy use of caching is required. But could not find suitable solution, which will work with subsonic. do I have to create separate layer for it and if yes, a short example would be helpful.
+2  A: 

I wrote a CacheUtil class for subsonic 2.x ActiveRecord. It's based on some code someone posted on the old subsonic forums. (This is from a forum that was deleted before the last forum was removed. This is why software forums should be permanent.) Here is an example of a cache Find method. You could adapt it to ss3. There are also inserts, fetchall, delete, clear, etc. Rob Connery said at the time that caching was problematic, and it was left out of ss2 on purpose. By using HttpRuntime.Cache I share the cache between a web application and service simultaneously. I believe I can do this since it's a small application, always on a single server.

public static RecordBase<T> Find<T, ListType>(object primaryKeyValue)
    where T: RecordBase<T>, new()
    where ListType: AbstractList<T, ListType>, new()
{
    string key = typeof(T).ToString();
    if(HttpRuntime.Cache[key] == null)
        FetchAll<T, ListType>();
    if(HttpRuntime.Cache[key] != null)
    {
        ListType collection = (ListType)HttpRuntime.Cache[key];
        foreach(T item in collection)
        {
            if(item.GetPrimaryKeyValue().Equals(primaryKeyValue))
                return item;
        }
    }
    return null;
}
P a u l
+1  A: 

I wrote a post about how I used caching with SubSonic 2.x. It isn't 100% compatible with 3.x but the concepts are the same.

John Sheehan