Exemple #1
0
 public IEnumerable<SearchItem> Search(string query)
 {
     var getter = new Func<List<SearchItem>>(() => {
         var googleSearch = new CustomSearch(Config.GoogleAPIKey, Config.GoogleCX);
         return googleSearch.Query(query).Items;
     });
     using (var googleCache = new ScopedCache(CacheType.Google)) {
         return googleCache.Get(query, MemCache.MidnightExpiration, getter);
     }
 }
Exemple #2
0
 public List<TopProject> GetTopProjects(string query, DateTime date)
 {
     var getter = (Func<List<TopProject>>)(() => {
         using (var warehouse = new DataWarehouseEntities()) {
             return warehouse.GetTopProjects(query, date).ToList();
         }
     });
     using (var dataWarehouse = new ScopedCache(CacheType.DataWarehouse)) {
         return dataWarehouse.Get(query + date.ToShortDateString(), TimeSpan.FromMinutes(60), getter);
     }
 }
Exemple #3
0
 public CountyExtent GetCountyExtent(string query)
 {
     var getter = (Func<CountyExtent>)(() => {
         using (var warehouse = new DataWarehouseEntities()) {
             return warehouse.GetCountyExtents(query).FirstOrDefault();
         }
     });
     using (var dataWarehouse = new ScopedCache(CacheType.DataWarehouse)) {
         return dataWarehouse.Get(query, TimeSpan.FromMinutes(60), getter);
     }
 }