Beispiel #1
0
 public void Cache(string searchTerm, CachedResult result)
 {
     lock (mutex)
     {
         cache.Set(searchTerm, result);
         cacheManager.Register(searchTerm);
     }
 }
Beispiel #2
0
        public bool TryGet(string searchTerm, out CachedResult cached)
        {
            cached = null;

            lock (mutex)
            {
                if (cache.TryGetValue(searchTerm.ToLowerInvariant(), out CachedResult result))
                {
                    logger.LogInformation($"Using cached value for: {searchTerm}.");

                    cached = result;
                    return(true);
                }
            }

            return(false);
        }