CSLA .NET

Vibrant discussion about CSLA .NET and using the framework to build great business applications.

Is there a better way to implement a server-side cache for Silverlight?

rated by 0 users
Not Answered This post has 0 verified answers | 4 Replies | 3 Followers

Top 150 Contributor
52 Posts
RobKraft posted on Fri, Apr 6 2012 12:06 PM

We want to cache data server side so that we don't need to make the database calls for every silverlight client.  Our objects are also used by Asp.Net web apps and desktop apps.  Ideally, I'd like to set the value of this to the collection that was cached, but that is not possible.

The only alternative we have come up with is to loop through the items in the cache calling this.Add.  That is probably better than a database call, but feels less efficient than "this = cache". 

Is there a way to implement something like this below?

private void DataPortal_Fetch(CriteriaHash criteria)
{
if (_cache != nulll)
{ this = _cache;
}
else
{_cache = GetData()//GetData adds to this;
}
}

All Replies

Top 10 Contributor
1,772 Posts

You may look into CslaContrib and the serverside caching with AppFabric. or plain InMemoryCache.

Uses a custom CacheDataPortal (serverside DataPortal)  and ObjectCacheAttribute and ObjectCacheEvictionAttribute at classlevel to determin if object is Cachable and when to evictfrom cache. All that is required is configuring to use the custom DataPortal and add attribute to the actual classes.

CacheAttribute is configurable for CacheScope (Global,Group,User).

Http://CslaContrib.codeplex.com 

Jonny Bekkum, Norway CslaContrib Coordinator

Top 150 Contributor
52 Posts

Thanks for the suggestion, I will look into that.

Top 50 Contributor
178 Posts
Tim replied on Mon, Sep 24 2012 7:51 AM

Are there any examples showing how to use the caching feature in CslaContrib?

Tim

Top 10 Contributor
9,270 Posts

You should also look at the ObjectFactory data portal concepts (factory encapsulation), because in an object factory you really _can_ just deserialize a copy of the object out of the cache and return it as the result.

public MyClass Fetch(CriteriaHash criteria)
{
  MyClass obj = null;
   // get object from cache, or from database
  MarkOld(obj);
  return obj;
}

 

Rocky

Page 1 of 1 (5 items) | RSS

Copyright (c) 2006-2010 Marimer LLC. All rights reserved.
Email admin@lhotka.net for support.
Powered by Community Server (Non-Commercial Edition), by Telligent Systems