Advertisement
Guest User

Umbraco Domain Caching

a guest
Jan 28th, 2013
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.87 KB | None | 0 0
  1. internal static List<Domain> GetDomains()
  2. {
  3.     return Cache.GetCacheItem<List<Domain>>("UmbracoDomainList", getDomainsSyncLock, TimeSpan.FromMinutes(30),
  4.         delegate
  5.         {
  6.             List<Domain> result = new List<Domain>();
  7.             using(IRecordsReader dr = SqlHelper.ExecuteReader(
  8.                                                     "select id, domainName from umbracoDomains"))
  9.             {
  10.                 while(dr.Read())
  11.                 {
  12.                     string domainName = dr.GetString("domainName");
  13.                     int domainId = dr.GetInt("id");
  14.  
  15.                     if (result.Find(delegate(Domain d) { return d.Name == domainName; }) == null)
  16.                         result.Add(new Domain(domainId));
  17.                     else
  18.                         Log.Add(LogTypes.Error, User.GetUser(0), -1,
  19.                             string.Format("Domain already exists in list ({0})", domainName));
  20.                 }
  21.             }
  22.             return result;
  23.         });
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement