In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article introduces how to use Redis in ServiceStack, the content is very detailed, interested friends can use for reference, I hope it can be helpful to you.
Redis is an open source API that is written in ANSI C language, supports the network, can be memory-based and persistent, and provides API in multiple languages.
Redis is a key-value storage system. Similar to Memcached, it supports relatively more value types, including string (string), list (linked list), set (collection), zset (sorted set-ordered collection), and hash (hash type).
Using Redis as cache can greatly improve the running efficiency of the system, and Redis can store more complex data types. ServiceStack also has a separate class library, which can support Redis connection, data storage, reading and other operations.
There is a Redis compiled to run directly on windows, which can be downloaded from a search on the Internet.
The following is a simple example of how to connect, store and read data. In the process of development, it is found that the query speed of hashtable in C# is much faster than that of list. You can convert the data into hashtable in advance and store it in redis. When you use it, take out hashtable to improve the efficiency of the query:
/ / initialize a client of redis, and set the connection address and port number of redis. If the port is not set, it will be the default port.
Var _ redisClient = new RedisClient ("localhost")
/ / simulate a hashtable in a loop without enumerating the real data
Hashtable _ hd1 = new Hashtable ()
For (int I = 0; I < 10000; iTunes +)
{
_ hd1.Add (I, I)
}
/ / the data stored in hashtable is stored in redis, preceded by the keyword hashtable
_ redisClient.Set ("_ hd1", _ hd1)
/ / obtain hashtable data in redis according to keywords
Hashtable _ test = _ redisClient.Get ("_ hd1")
/ / customize a simple class that contains two string parameters
Public class Tmodel
{
Public string Prop1 {get; set;}
Public string Prop2 {get; set;}
}
/ / it is also possible to store a class of list type
_ redisClient.Set ("_ lsT1", _ lstModel)
ServiceStack package is relatively simple, can be quickly called through a few lines of code, and can improve the efficiency of the system.
On how to use Redis in ServiceStack to share here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.