當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。