Skip to content

Instantly share code, notes, and snippets.

@ebello
Created July 31, 2008 17:32
Show Gist options
  • Save ebello/3485 to your computer and use it in GitHub Desktop.
Save ebello/3485 to your computer and use it in GitHub Desktop.
public delegate BaseGenericList<T> MethodExecution<T>();
public static BaseGenericList<T> GetCachedList<T>(string key, object[] argsKey, MethodExecution<T> method)
{
BaseGenericList<T> list = new BaseGenericList<T>();
T[] listarray = (T[])CacheConfig.DeCache(key, argsKey);
if (listarray == null)
{
list = method();
CacheConfig.EnCache(key, list.ToArray(), argsKey);
}
else
{
list.AddRange(listarray);
}
return list;
}
// calling
BaseGenericList<Event> eventlist = CacheConfig.GetCachedList<Event>("EventsList", new object[] { GroupID, start, end, start_index, max_results }, delegate() { return iobj.GetEvents(GroupID, start, end, start_index, max_results, out temp_total_results); });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment