public IPartitionedCache <T> Resolve <T>(string key) { if (!CachePartitions.TryGetValue(key, out var partitionedCache)) { throw new InvalidOperationException($"Cannot insert a cache partition with the same key {key}"); } return((IPartitionedCache <T>)partitionedCache); }
public bool TryAddPartition <T>(string key, MemoryCacheOptions memoryCacheOptions = null) { if (CachePartitions.TryGetValue(key, out _)) { return(false); } if (memoryCacheOptions == null) { CachePartitions.Add(key, new PartitionedCache <T>(new MemoryCache(new MemoryCacheOptions()))); } else { CachePartitions.Add(key, new PartitionedCache <T>(new MemoryCache(memoryCacheOptions))); } return(true); }