private static ICacheCreator CreateCache(string name) { ICacheCreator creator = PlugInFactoryManager.CreateInstance <ICacheCreator>( CacheCreatorPlugInFactory.REG_NAME, name); return(creator); }
public object GetCacheItem(string cacheName, string key, params object[] args) { TkDebug.AssertArgumentNullOrEmpty(cacheName, "cacheName", this); TkDebug.AssertArgumentNullOrEmpty(key, "key", this); ICache cache = GetCache(cacheName); BaseCacheItemCreator creator = PlugInFactoryManager.CreateInstance <BaseCacheItemCreator>( CacheItemCreatorPlugInFactory.REG_NAME, cacheName); TkDebug.AssertNotNull(creator, $"{cacheName}不存在", this); if (cache == null) { ICacheCreator cacheCreator = creator.CacheCreator; if (cacheCreator == null) { cacheCreator = creator.SupportDistributed ? DefaultDistributedCreator : DefaultCreator; } cache = cacheCreator.CreateCache(cacheName); CacheLock.WriteLockAction(() => { if (!fCaches.ContainsKey(cacheName)) { fCaches.Add(cacheName, cache); return(true); } return(false); }); } return(cache.GetItem(creator.TransformCacheKey(key), creator, args)); }
protected BaseCacheItemCreator(ICacheCreator cacheCreator) { TkDebug.AssertArgumentNull(cacheCreator, "cacheCreator", null); CacheCreator = cacheCreator; Initialize(); }
public MemoryCache(string name, ICacheCreator creator) { if(string.IsNullOrWhiteSpace(name)) throw new ArgumentNullException("name"); _innerCache = new System.Runtime.Caching.MemoryCache(name); _creator = creator; }
public MemoryCache(string name, ICacheCreator creator) { if (string.IsNullOrWhiteSpace(name)) { throw new ArgumentNullException("name"); } _innerCache = new System.Runtime.Caching.MemoryCache(name); _creator = creator; }
public MemoryCache(string name, ICacheCreator creator) { if (string.IsNullOrWhiteSpace(name)) { throw new ArgumentNullException("name"); } _creator = creator; _name = name; #if !CORE_CLR _innerCache = new System.Runtime.Caching.MemoryCache(name); #else _innerCache = new Microsoft.Extensions.Caching.Memory.MemoryCache(new MemoryCacheOptions()); #endif }
protected DistributeCacheItemCreator(ICacheCreator cacheCreator) : base(cacheCreator) { }