Welcome Guest, you are in: Namespace

The SueetieCache class contains enhancements to HttpContext server caching, making it easier to use caching to improve Sueetie performance.

SueetieCache - Patterns

The SueetieCache Class is essentially a helper function to make it more efficient to work with the HttpContext.Current.Cache object. A sample use of caching would be in obtaining a User object, where SueetieCache is checked for the presence of a User object by unique caching key and if not, retrieved from the database and then placed into SueetieCache.

public static SueetieUser GetUser(int userID)
{
	string userCacheKey = UserCacheKey(userID);
	SueetieUser sueetieUser = 
	   SueetieCache.Current[userCacheKey]as SueetieUser;
	if (sueetieUser == null)
	{
	   SueetieDataProvider _provider = SueetieDataProvider.LoadProvider();
	   sueetieUser = _provider.GetUser(userID);
	   SueetieCache.Current.Insert(userCacheKey, sueetieUser);
	}
	return sueetieUser;
}

The statement which checks for the existence of SueetieUser in the cache is

SueetieUser sueetieUser = SueetieCache.Current[userCacheKey] as SueetieUser;

Caching functions with overrides in SueetieCache include

  1. Add()
  2. Insert()
  3. InsertMax()
  4. InsertMinutes()
  5. Remove()

SueetieCache - Origins

As with SueetieContext, we're leveraging the patterns established in YetAnotherForum.NET for handling Caching in the Sueetie Framework. I personally like the bracket-based CacheKey syntax as in the earlier example.

SueetieUser sueetieUser = SueetieCache.Current[userCacheKey] as SueetieUser;

This comes from the YAFCache utility class approach being used in Sueetie.

public object this[string key]
{
   get
   {
      return _cache[key];
   }
   set
   {
      _cachekey = value;
   }
}



For additional reference, here is the location of the YAF.NET Caching class.

YetAnotherForum.NET Class.Utils library

Top

ScrewTurn Wiki version 3.0.4.560.

Copyright © 2008-2012 Sueetie LLC. All rights reserved.
Sueetie