public static IDataStore GetStorage(string configpath, string tenant, string module, IQuotaController controller) { var tenantId = -2; if (string.IsNullOrEmpty(tenant)) { tenant = DefaultTenantName; } else { tenantId = Convert.ToInt32(tenant); } //Make tenant path tenant = TenantPath.CreatePath(tenant); var store = DataStoreCache.Get(tenant, module); if (store == null) { var section = GetSection(configpath); if (section == null) { throw new InvalidOperationException("config section not found"); } var settings = StorageSettings.LoadForTenant(tenantId); store = GetStoreAndCache(tenant, module, section, settings.DataStoreConsumer, controller); } return(store); }
private static IDataStore GetStoreAndCache(string tenant, string module, StorageConfigurationSection section, DataStoreConsumer consumer, IQuotaController controller) { var store = GetDataStore(tenant, module, section, consumer, controller); if (store != null) { DataStoreCache.Put(store, tenant, module); } return(store); }
private IDataStore GetStoreAndCache(string tenant, string module, DataStoreConsumer consumer, IQuotaController controller) { var store = GetDataStore(tenant, module, consumer, controller); if (store != null) { DataStoreCache.Put(store, tenant, module); } return(store); }
public void Subscribe() { if (Subscribed) { return; } lock (locker) { if (Subscribed) { return; } Subscribed = true; Cache.Subscribe((r) => DataStoreCache.Remove(r.TenantId, r.Module), CacheNotifyAction.Remove); } }
public static IDataStore GetStorage(string configpath, string tenant, string module, IQuotaController controller) { var tenantId = -2; if (string.IsNullOrEmpty(tenant)) { tenant = DefaultTenantName; } else { tenantId = Convert.ToInt32(tenant); } //Make tenant path tenant = TenantPath.CreatePath(tenant); var store = DataStoreCache.Get(tenant, module); if (store == null) { var sectionKey = "StorageConfigurationSection" + (configpath ?? "").Replace("\\", "").Replace("/", ""); var section = AscCache.Memory.Get <StorageConfigurationSection>(sectionKey); if (section == null) { section = GetSection(configpath); AscCache.Memory.Insert(sectionKey, section, DateTime.MaxValue); } if (section == null) { throw new InvalidOperationException("config section not found"); } var settings = StorageSettings.LoadForTenant(tenantId); store = GetStoreAndCache(tenant, module, section, settings.DataStoreConsumer, controller); } return(store); }
public static IDataStore GetStorage(string configpath, string tenant, string module, IQuotaController controller) { if (tenant == null) { tenant = DefaultTenantName; } //Make tennant path tenant = TennantPath.CreatePath(tenant); var store = DataStoreCache.Get(tenant, module); if (store == null) { var section = GetSection(configpath); if (section == null) { throw new InvalidOperationException("config section not found"); } store = GetStoreAndCache(tenant, module, section, controller); } return(store); }
static StorageFactory() { Cache = AscCache.Notify; Cache.Subscribe <DataStoreCacheItem>((r, act) => DataStoreCache.Remove(r.TenantId, r.Module)); }
public StorageFactoryListener(ICacheNotify <DataStoreCacheItem> cache) { cache.Subscribe((r) => DataStoreCache.Remove(r.TenantId, r.Module), CacheNotifyAction.Remove); }
static StorageFactory() { Cache = new KafkaCache <DataStoreCacheItem>(); Cache.Subscribe((r) => DataStoreCache.Remove(r.TenantId, r.Module), CacheNotifyAction.Remove); Section = new Lazy <Configuration.Storage>(() => CommonServiceProvider.GetService <Configuration.Storage>(), true); }