コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
ファイル: StorageFactory.cs プロジェクト: y2ket/AppServer
        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);
        }
コード例 #4
0
ファイル: StorageFactory.cs プロジェクト: ztcyun/AppServer
        public void Subscribe()
        {
            if (Subscribed)
            {
                return;
            }

            lock (locker)
            {
                if (Subscribed)
                {
                    return;
                }

                Subscribed = true;
                Cache.Subscribe((r) => DataStoreCache.Remove(r.TenantId, r.Module), CacheNotifyAction.Remove);
            }
        }
コード例 #5
0
        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);
        }
コード例 #6
0
        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);
        }
コード例 #7
0
 static StorageFactory()
 {
     Cache = AscCache.Notify;
     Cache.Subscribe <DataStoreCacheItem>((r, act) => DataStoreCache.Remove(r.TenantId, r.Module));
 }
コード例 #8
0
ファイル: StorageFactory.cs プロジェクト: y2ket/AppServer
 public StorageFactoryListener(ICacheNotify <DataStoreCacheItem> cache)
 {
     cache.Subscribe((r) => DataStoreCache.Remove(r.TenantId, r.Module), CacheNotifyAction.Remove);
 }
コード例 #9
0
 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);
 }