public void Remove(CacheLocation entity) { using (var client = _manager.GetClient()) { var redisValue = JsonConvert.SerializeObject(entity); client.RemoveItemFromSortedSet(_locationsKey, redisValue); } }
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))); } }
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; }; } }
/// <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>(); }
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); }
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>(); }
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); }
public void SetOptions(CacheLocation cacheLocation) { _cacheLocation = cacheLocation; }
public void Post([FromBody] CacheLocation value) { _locationService.StoreLocation(value); }
public void StoreLocation(CacheLocation location) { _db.Write(location); }
public void StoreLocation(CacheLocation location) { _manager.StoreLocation(location); }
public void SetOptions(CacheLocation cacheLocation) { return; }
public void SetOptions(CacheLocation cacheLocation) { cache.SetOptions(cacheLocation); }