Redis Simple Read and write

Source: Internet
Author: User

Redis Simple Read and write

Record key value.

First of all to refer to Redes, or code to speak it. Trouble.

Link Way//reference public   static Pooledredisclientmanager poolreds;//This corresponding Redis library        static int port = 1;        Static Redispool ()        {            try            {                //For the password IP port of the Redis library             redisurlopenid= "Password @ip: port" poolreds = new Pooledredisclientmanager (port, new string[] {configurationmanager.appsettings["Redisurlopenid"]}); } catch (Exception ex) {}}

For the above: write

<summary>
Cache to Redis
</summary>
<param name= "key" >key value </param>
<param name= "Danhaolist" > Detailed information </param>
public static void Enqueuelist (string key, String obj)
{
using (var client = poolreds. Getclient ())
{
Queue usage
if (obj! = null)
{
Client. Additemtolist (key, obj);
}
}
}

  

For the above: read

<summary>
Reads the current
</summary>
<param name= "Key" ></param>
<returns></returns>
public static string Dequeuemodel (String key)
{
using (var client = poolreds. Getclient ())
{
String Danhao = client. Getitemfromlist (key, 0);
return Danhao;
}
}


  

<summary>
Determine if there is currently a record
</summary>
<param name= "Key" ></param>
<returns></returns>
public static long GetListCount (string key)
{
using (var client = poolreds. Getclient ())
{
Long Count = client. GetListCount (key);
return count;
}
}

  

This is inserted into a list.

INSERT into the unified kjgz2016-04-08 list.

The list can also be inserted into many records. A key for many value. Can record a lot of things. A very useful kind of

The layout is not very good. Hey... And there's the back!

Redis Simple Read and write

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.