Пример #1
0
 public T Find <T>(string key)
 {
     return((T)cache.GetOrAdd(key, k =>
     {
         var serializedValue = fileSystemHandler.ReadUTF8(GetFileName(k));
         return jsonSerializer.Deserialize <T>(serializedValue);
     }));
 }
Пример #2
0
        public T[] GetAll()
        {
            if (storedValue != null)
            {
                return(storedValue);
            }

            lock (changeLock)
            {
                var str    = fileSystemHandler.ReadUTF8(fileName);
                var result = string.IsNullOrEmpty(str) ? new T[0] : jsonSerializer.Deserialize <T[]>(str);
                storedValue = result;
                return(result);
            }
        }