Share a Redis helper class

Source: Internet
Author: User

Redis was recently used in the project to store downloaded URLs, and the project used Servicestack to operate Redis, beginning with the latest version of Servicestack and later found Servicestack has been commercialized, and the non-commercial version can only operate 6,000 redis per hour, later replacing Servicestack with the V3 version.

A Redis hash set was used in the project, but the Servicestack package was inconvenient to use, so it encapsulated a DLL and used the Servicestack pool to dynamically create iredisclient instances. An abstract class has been created Redisoperatorbase encapsulates some basic methods. Relatively simple, I believe you see the code will be.

Code github:https://github.com/dazhuangtage/redisdemo/

The following is the simplest use:

First configure the File configuration node:

<configSections> <section name="Redistools"Type="Redistools.redisconfig, Redistools"/> </configSections> <redistools writeserverlist="127.0.0.1:6379"readserverlist="[Email protected]:6379"Maxwritepoolsize=" -"Maxreadpoolsize=" -"autostart="true"Localcachetime=" the"recordelog="false"/></configuration>

How to use:

        /// <summary>        ///The main entry point for the application. /// </summary>        Static voidMain (string[] args) {            varHashoperator =NewHashoperator (); Hashoperator.set ("Test","name","Big strong his brother"); Console.WriteLine (Hashoperator.get<string> ("Test","name"));        Console.readkey (); }    

If you want to extend a helper class, just inherit the redisoperatorbase.

Share a Redis helper class

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.