111111
作者:互联网
1 public class FileService 2 { 3 private readonly ConcurrentDictionary<string, byte[]> _cache; 4 5 public FileService() 6 { 7 _cache = new ConcurrentDictionary<string, byte[]>(); 8 } 9 10 public byte[] GetFileContent(string filePath) 11 { 12 return _cache.GetOrAdd(filePath, _ => 13 { 14 return File.ReadAllBytes(filePath); 15 }); 16 } 17 }
标签:return,filePath,cache,ConcurrentDictionary,111111,FileService,public 来源: https://www.cnblogs.com/Johnfx-home/p/12384660.html