コード例 #1
0
 public void Remove(CacheLocation entity)
 {
     using (var client = _manager.GetClient())
     {
         var redisValue = JsonConvert.SerializeObject(entity);
         client.RemoveItemFromSortedSet(_locationsKey, redisValue);
     }
 }
コード例 #2
0
 public IEnumerable <CacheLocation> GetMembersByRadius(CacheLocation currentUserLocation, double radiusInMeters = 1000)
 {
     using (var client = _manager.GetClient())
     {
         var result = client.FindGeoMembersInRadius(_locationsKey, currentUserLocation.Lng, currentUserLocation.Lat, radiusInMeters, "m");
         return(result.Select(x => JsonConvert.DeserializeObject <CacheLocation>(x)));
     }
 }
コード例 #3
0
 public void Write(CacheLocation entity)
 {
     using (var client = _manager.GetClient())
     {
         client.Set(entity.Key, entity.Nick, DateTime.Now.AddSeconds(30));
         client.AddGeoMember("Sicily", entity.Lng, entity.Lat, entity.Key);
         var sub = client.CreateSubscription();
         sub.SubscribeToChannels(entity.Key);
         sub.OnMessage = (x, y) =>
         {
             var s = x + y;
         };
     }
 }
コード例 #4
0
ファイル: UnityConfig.cs プロジェクト: knyazkov-ma/HelpDesk
        /// <summary>Registers the type mappings with the Unity container.</summary>
        /// <param name="container">The unity container to configure.</param>
        /// <remarks>There is no need to register concrete types such as controllers or API controllers (unless you want to
        /// change the defaults), as Unity allows resolving a concrete type even if it was not previously registered.</remarks>
        public static void RegisterTypes(IUnityContainer container)
        {
            // NOTE: To load from web.config uncomment the line below. Make sure to add a Microsoft.Practices.Unity.Configuration to the using statements.
            // container.LoadConfiguration();

            // TODO: Register your types here
            // container.RegisterType<IProductRepository, ProductRepository>();

            //string connectionString = WebConfigurationManager.ConnectionStrings["cs"].ConnectionString;

            string   hibernateCfgFileName = System.Web.Hosting.HostingEnvironment.MapPath("~/bin/hibernate.cfg.xml");
            XElement root  = XElement.Load(hibernateCfgFileName);
            var      nsMgr = new XmlNamespaceManager(new NameTable());

            nsMgr.AddNamespace("NC", "urn:nhibernate-configuration-2.2");
            string connectionString = root.XPathSelectElement("//NC:property[@name='connection.connection_string']", nsMgr).Value;

            //регистрация NHibernate-репозиториев
            NHibernateDataInstaller.Install(container, new PerRequestLifetimeManager());
            NHibernateRepositoryInstaller.Install(container);

            //регистрация кэша
            string redisConnectionString = WebConfigurationManager.AppSettings["cache:RedisConnectionString"];

            CacheLocation defaultLocation = CacheLocation.InMemory;

            Enum.TryParse(WebConfigurationManager.AppSettings["cache:DefaultLocation"], out defaultLocation);


            CacheInstaller.Install(redisConnectionString, defaultLocation, container, new PerRequestLifetimeManager());

            //регистрация Мигратора
            MigratorInstaller.Install(container, connectionString);

            DataServiceCommonInstaller.Install(container);
            //регистрация дата-сервисов
            DataServiceInstaller.Install(container);

            //регистрация шины
            EventBusInstaller.Install(container,
                                      WebConfigurationManager.AppSettings["RabbitMQHost"],
                                      WebConfigurationManager.AppSettings["ServiceAddress"],
                                      WebConfigurationManager.AppSettings["RabbitMQUserName"],
                                      WebConfigurationManager.AppSettings["RabbitMQPassword"]);

            container.RegisterType <JsResourceHelper>();
        }
コード例 #5
0
ファイル: CloudHelper.cs プロジェクト: g76812791/cache
        public static CloudBlobClient GetCloudBlobClientReference(CacheLocation cacheLocation = CacheLocation.East)
        {
            var connString = string.Empty;

            if (CustomSettingsHelper.IsDevEnviroment() != TrendsEnvironment.Prod)
            {
                connString = CustomSettingsHelper.GetStorageConnectionString(StorageKeys.cache);
            }
            else
            {
                connString = cacheLocation == CacheLocation.East
            ? CustomSettingsHelper.GetStorageConnectionString(StorageKeys.cache)
            : "DefaultEndpointsProtocol=https;AccountName=3xcache2;AccountKey=8cGuZ3JxUqG3EIKzHW5NqSnRQvMZ3XrN+fCN4F28K8t4GRt8u8BhXh9sIO+7sNCfpAk9Mts1fYkTWjcae2ewNw==;EndpointSuffix=core.windows.net";
            }
            var storageAccount = CloudStorageAccount.Parse(connString);
            var storageClient  = storageAccount.CreateCloudBlobClient();

            return(storageClient);
        }
コード例 #6
0
        public static void Install(string redisConnectionString, CacheLocation defaultLocation, IUnityContainer container, LifetimeManager lifetimeManager)
        {
            _container       = container;
            _defaultLocation = defaultLocation;

            if (!String.IsNullOrWhiteSpace(redisConnectionString))
            {
                _container.RegisterType <ICacheClient>(lifetimeManager,
                                                       new InjectionFactory(c => RedisClientFactory.Instance.GetCurrent(redisConnectionString)));

                _container.RegisterType <ICache, RedisCache>(_defaultLocation.ToString());
            }
            else
            {
                _container.RegisterType <ICache, MemoryCache>(_defaultLocation.ToString());
            }


            _container.RegisterType <IMemoryCache, MemoryCache>();
        }
コード例 #7
0
        private static void RunTest(CacheLocation location)
        {
            var provider = Locator.Get <ICache>(location);

            provider.Set("TestCache1", new CacheObj {
                Name = "TestCache1"
            });
            var obj1 = provider.Get <CacheObj>("TestCache1");

            Assert.IsNotNull(obj1);
            Assert.IsTrue(obj1.Name == "TestCache1");


            provider.Set("TestCache2", new CacheObj {
                Name = "TestCache2"
            }, 1, "TestRegion");
            provider.ClearRegion("TestRegion");
            var obj2 = provider.Get <CacheObj>("TestCache2", "TestRegion");

            Assert.IsNull(obj2);
        }
コード例 #8
0
 public void SetOptions(CacheLocation cacheLocation)
 {
     _cacheLocation = cacheLocation;
 }
コード例 #9
0
 public void Post([FromBody] CacheLocation value)
 {
     _locationService.StoreLocation(value);
 }
コード例 #10
0
 public void StoreLocation(CacheLocation location)
 {
     _db.Write(location);
 }
コード例 #11
0
 public void StoreLocation(CacheLocation location)
 {
     _manager.StoreLocation(location);
 }
コード例 #12
0
 public void SetOptions(CacheLocation cacheLocation)
 {
     return;
 }
コード例 #13
0
ファイル: CacheProvider.cs プロジェクト: g76812791/cache
 public void SetOptions(CacheLocation cacheLocation)
 {
     cache.SetOptions(cacheLocation);
 }