public JArray GetSoftwares(string shortname) { JArray jResult = new JArray(); //Try to get value from Memory if (_cache.TryGetValue("sn-" + shortname.ToLower(), out jResult)) { return(jResult); } jResult = RZRestAPIv2.GetSoftwares(shortname); if (jResult.Count > 0) { var cacheEntryOptions = new MemoryCacheEntryOptions().SetSlidingExpiration(TimeSpan.FromSeconds(SlidingExpiration)); //cache hash for x Seconds _cache.Set("sn-" + shortname.ToLower(), jResult, cacheEntryOptions); return(jResult); } return(new JArray()); }
public JArray GetSoftwares(string name = "", string ver = "", string man = "_unknown") { JArray jResult = new JArray(); try { if (string.IsNullOrEmpty(man)) { man = "_unknown"; } //Try to get value from Memory if (_cache.TryGetValue("mnv-" + Base.clean(man).ToLower() + Base.clean(name).ToLower() + Base.clean(ver).ToLower(), out jResult)) { return(jResult); } jResult = RZRestAPIv2.GetSoftwares(name, ver, man); if (jResult.Count > 0) { UpdateURLs(ref jResult); //Update URL's before caching to cache the change... var cacheEntryOptions = new MemoryCacheEntryOptions().SetSlidingExpiration(TimeSpan.FromSeconds(SlidingExpiration)); //cache hash for x Seconds _cache.Set("mnv-" + Base.clean(man).ToLower() + Base.clean(name).ToLower() + Base.clean(ver).ToLower(), jResult, cacheEntryOptions); return(jResult); } } catch (Exception ex) { Console.WriteLine("ERROR: GetSoftwares - " + ex.Message); } return(new JArray()); }