当前位置: 首页>>代码示例>>C#>>正文


C# RedisClient.GetTypedClient方法代码示例

本文整理汇总了C#中ServiceStack.Redis.RedisClient.GetTypedClient方法的典型用法代码示例。如果您正苦于以下问题:C# RedisClient.GetTypedClient方法的具体用法?C# RedisClient.GetTypedClient怎么用?C# RedisClient.GetTypedClient使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ServiceStack.Redis.RedisClient的用法示例。


在下文中一共展示了RedisClient.GetTypedClient方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Page_Load

        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                redisHost = ConfigurationManager.AppSettings["redisHost"];
                redisPort = int.Parse(ConfigurationManager.AppSettings["redisPort"]);
                redisPassword = ConfigurationManager.AppSettings["redisPassword"];

                if (!IsPostBack)
                {
                    RedisClient redisClient = new RedisClient(redisHost, redisPort) { Password = redisPassword };
                    using (var redisGuids = redisClient.GetTypedClient<Guids>())
                    {
                        redisGuids.Store(new Guids { Date = DateTime.Now, Value = Guid.NewGuid() });
                        var allValues = redisGuids.GetAll();
                        GridView1.DataSource = allValues;
                        GridView1.DataBind();
                    }
                }
            }
            catch (Exception ex)
            {
                throw new WebException(ex.ToString(), WebExceptionStatus.ConnectFailure);
            }
        }
开发者ID:UhuruSoftware,项目名称:vcap-dotnet,代码行数:25,代码来源:default.aspx.cs

示例2: RedisQueueClient

		/// <summary>
		/// Ctor. Obtains and stores a reference to a typed Redis client.
		/// </summary>
		public RedisQueueClient()
		{
			_client = new RedisClient(Settings.Default.RedisHost, Settings.Default.RedisPort);
			_taskMessageClient = _client.GetTypedClient<TaskMessage>();

			_log.Info("Connected to Redis.");
			_log.DebugFormat("Connection Properties: {0}:{1}",
				Settings.Default.RedisHost, Settings.Default.RedisPort);
		}
开发者ID:yiannisk,项目名称:RedisQueue.Mono,代码行数:12,代码来源:RedisQueueClient.cs

示例3: GetChangesFor

        private List<PlayEvent<StubModel>> GetChangesFor(string modelId)
        {
            using (var redisClient = new RedisClient())
            {
                var redis = redisClient.GetTypedClient<PlayEvent<StubModel>>();

                return redis.Lists["urn:changes:" + modelId].GetAll();
            }
        }
开发者ID:baseman,项目名称:SimpleCommunicator,代码行数:9,代码来源:CommandController.cs

示例4: StoreInHash

        public static void StoreInHash(string key, string value)
        {
            using (IRedisClient client = new RedisClient())
            {
                var objClient = client.GetTypedClient<string>();

                var hash = objClient.GetHash<string>(keyPredicate + key.ToString());

                hash.Add(key, value);
            }
        }
开发者ID:krstan4o,项目名称:TelerikAcademy,代码行数:11,代码来源:RedisDbActions.cs

示例5: ClearAllChanges

        public JsonResult ClearAllChanges()
        {
            using (var redisClient = new RedisClient())
            {
                var redis = redisClient.GetTypedClient<StubAddedEvent>();

                redis.SetSequence(0);
                redis.FlushAll();
            }

            return this.Json("Changes cleared");
        }
开发者ID:baseman,项目名称:SimpleCommunicator,代码行数:12,代码来源:CommandController.cs

示例6: RedisQueueService

		public RedisQueueService(Uri baseUri, bool resume)
		{
			using (RedisClient redisClient = new RedisClient())
			{
				_redis = redisClient.GetTypedClient<Entry>();
				_queue = _redis.Lists[string.Format("barcodes:{0}:queue", baseUri)];
				if (!resume)
				{
					_queue.Clear();
				}
			}
		}
开发者ID:senzacionale,项目名称:ncrawler,代码行数:12,代码来源:RedisQueueService.cs

示例7: RedisHistoryService

		public RedisHistoryService(Uri baseUri, bool resume)
		{
			using (RedisClient redisClient = new RedisClient())
			{
				_redis = redisClient.GetTypedClient<string>();
				_history = _redis.Sets[string.Format("barcodes:{0}:history", baseUri)];
				if (!resume)
				{
					_history.Clear();
				}
			}
		}
开发者ID:senzacionale,项目名称:ncrawler,代码行数:12,代码来源:RedisHistoryService.cs

示例8: GetValue

        public static string GetValue(string key)
        {
            string returnedValue;
            using (IRedisClient client = new RedisClient())
            {

                var objClient = client.GetTypedClient<string>();

                var hash = objClient.GetHash<string>(keyPredicate + key);
                returnedValue = hash[key];
            }

            return returnedValue;
        }
开发者ID:krstan4o,项目名称:TelerikAcademy,代码行数:14,代码来源:RedisDbActions.cs

示例9: Index

        public ViewResult Index()
        {
            var redis = new RedisClient();

            using (var redisStatus = redis.GetTypedClient<UserStatus>())
            {
                var allstatus = redisStatus.GetAll();

                var query = (from items in allstatus
                             select items).ToList();

                return View(query);
            }

        }
开发者ID:vijayantkatyal,项目名称:RedisApp_ASP.NET_Demo,代码行数:15,代码来源:HomeController.cs

示例10: Button2_Click

        protected void Button2_Click(object sender, EventArgs e)
        {
            string redisHost = ConfigurationManager.AppSettings["redisHost"];
            int redisPort = int.Parse(ConfigurationManager.AppSettings["redisPort"]);
            string redisPassword = ConfigurationManager.AppSettings["redisPassword"];

            RedisClient redisClient = new RedisClient(redisHost, redisPort) { Password = redisPassword };
            using (var redisGuids = redisClient.GetTypedClient<Guids>())
            {
                redisGuids.DeleteAll();
                var allValues = redisGuids.GetAll();
                GridView1.DataSource = allValues;
                GridView1.DataBind();
            }
        }
开发者ID:UhuruSoftware,项目名称:vcap-dotnet,代码行数:15,代码来源:default.aspx.cs

示例11: Edit

        public ActionResult Edit(int id)
        {
            var redis = new RedisClient();

            using (var redisstatus = redis.GetTypedClient<UserStatus>())
            {

                // Call all items then , select item using id of item
                // we don't know id of item stored 
                // in redis , so search is required.

                var item = redisstatus.GetAll().Where(i => i.id.Equals(id));
                return View(item.First());
            }

        }
开发者ID:vijayantkatyal,项目名称:RedisApp_ASP.NET_Demo,代码行数:16,代码来源:HomeController.cs

示例12: QueueClient

		public QueueClient(string host, int port, bool enableCaching)
		{
			RedisHost = host;
			RedisPort = port;

			GenericClient = new RedisClient(RedisHost, RedisPort);
			TypedClient = GenericClient.GetTypedClient<TaskMessage>();
			
			Log.Info("Connected to Redis.");
			Log.DebugFormat("Connection Properties: {0}:{1}", Settings.Default.RedisHost, Settings.Default.RedisPort);
			
			LocalCachingEnabled = enableCaching;
			if (LocalCachingEnabled)
			{
				Log.Info("Caching 's enabled. Cache location: " + Settings.Default.LocalCache);
				CheckCacheAndRetrieveState();
			}
		}
开发者ID:e-travel,项目名称:RedisQueue.Net,代码行数:18,代码来源:QueueClient.cs

示例13: Create

        public ActionResult Create(UserStatus status)
        {
            if (ModelState.IsValid)
            {
                var redis = new RedisClient();

                using (var redisStatus = redis.GetTypedClient<UserStatus>())
                {
                    redisStatus.Store(new UserStatus { id = (int) redisStatus.GetNextSequence(), name = status.name, description = status.description });
                }

                return RedirectToAction("Index");
            }
            else
            {
                ViewBag.status = "Invalid";
                return View();
            }
        }
开发者ID:vijayantkatyal,项目名称:RedisApp_ASP.NET_Demo,代码行数:19,代码来源:HomeController.cs

示例14: GetKeysAndValues

        public static List<KeyValuePair<string, string>> GetKeysAndValues()
        {
            List<KeyValuePair<string, string>> result = new List<KeyValuePair<string, string>>();
            using (IRedisClient client = new RedisClient())
            {

                var objClient = client.GetTypedClient<string>();

                var keys = objClient.GetAllKeys().Where(x => x.StartsWith(keyPredicate));

                foreach (var key in keys)
                {
                    var hash = objClient.GetHash<string>(key);
                    var word = key.Substring(keyPredicate.Length);
                    var val = hash[word];
                    result.Add(new KeyValuePair<string, string>(word, val));
                }
            }

            return result;
        }
开发者ID:krstan4o,项目名称:TelerikAcademy,代码行数:21,代码来源:RedisDbActions.cs

示例15: Main

        static void Main(string[] args)
        {
            /*** String ***/
            using (IRedisNativeClient client = new RedisClient())
            {
                client.Set("urn:messages:1", Encoding.UTF8.GetBytes("Hello C# World!"));
            }

            using (IRedisNativeClient client = new RedisClient())
            {
                var result = Encoding.UTF8.GetString(client.Get("urn:messages:1"));
                Console.WriteLine("Message: {0}", result);

            }
            /*** Lists ***/
            using (IRedisClient client = new RedisClient())
            {
                var customerNames = client.Lists["urn:customernames"];
                customerNames.Clear();
                customerNames.Add("Joe");
                customerNames.Add("Mary");
                customerNames.Add("Bob");
            }

            using (IRedisClient client = new RedisClient())
            {
                var customerNames = client.Lists["urn:customernames"];

                foreach (var customerName in customerNames)
                {
                    Console.WriteLine("Customer {0}", customerName);
                }
            }
            /*** Object ***/
            long lastId = 0;
            using (IRedisClient client = new RedisClient())
            {
                var customerClient = client.GetTypedClient<Customer>();
                var customer = new Customer()
                {
                    Id = customerClient.GetNextSequence(),
                    Address = "123 Main St",
                    Name = "Bob Green",
                    Orders = new List<Order>
                    {
                        new Order { OrderNumber = "AB123"},
                        new Order { OrderNumber = "AB124"}
                    }
                };
                var storedCustomer = customerClient.Store(customer);
                lastId = storedCustomer.Id;
            }

            using (IRedisClient client = new RedisClient())
            {
                var customerClient = client.GetTypedClient<Customer>();
                var customer = customerClient.GetById(lastId);

                Console.WriteLine("Got customer {0}, with name {1}", customer.Id, customer.Name);
            }
            /*** Transaction ***/
            using (IRedisClient client = new RedisClient())
            {
                var transaction = client.CreateTransaction();
                transaction.QueueCommand(c => c.Set("abc", 1));
                transaction.QueueCommand(c => c.Increment("abc", 1));
                transaction.Commit();

                var result = client.Get<int>("abc");
                Console.WriteLine(result);
            }
            /*** Publishing & Subscribing ***/
            using (IRedisClient client = new RedisClient())
            {
                client.PublishMessage("debug", "Hello C#!");

                var sub = client.CreateSubscription();
                sub.OnMessage = (c, m) => Console.WriteLine("Got message {0}, from channel {1}", m, c);
                sub.SubscribeToChannels("news");
            }

            Console.ReadLine();
        }
开发者ID:rjourde,项目名称:redis-demo,代码行数:83,代码来源:Program.cs


注:本文中的ServiceStack.Redis.RedisClient.GetTypedClient方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。