Stackexchange.redis Study Notes (iii) database and password configuration getserver function

Source: Internet
Author: User

This chapter mainly writes about the Stackexchange.redis configuration and the less frequently used functions

Database connection

Here is my connection string, which specifies the address, password, and default database

Redis startup is divided into 0-15 databases by default, keys can be duplicated between different databases, Stackexchange.redis's Getdatabase function provides an optional DB parameter

The default-1 is actually 0, and you can specify which database to connect by setting the DefaultDatabase in the connection string.

The operation of the specified database is more appropriate to be divided by business

Execute

Redis commands can be executed directly in Stackexchange.redis through the execute function, but for most command stackexchange.redis the Database will provide a way to encapsulate , so theoretically it is not necessary to call the Execute function

The following code is equivalent to calling the stringset and stringget functions of idatabase

Getserver

However, there are some more common functions that cannot be performed by the functions provided in idababase, such as Keys,flushdb,scan. What is this for?

The reason for this is that Stackexchange.redis provides functions such as stringset,setadd for a db cluster , so actually adding a key is not necessarily added to a single server.

Operations such as FLUSHDB are operations on a single database on a specific server (server) . Imagine if you provide a FLUSHDB operation for the entire cluster, in case of accidental deletion, the consequences are unthinkable ...

Of course Stackexchange.redis also provides relevant functions for the server. You can specify the specific server through the getserver of the connectionmultiplexer instance, where you need to set up the specific servers address and port number.

You can then call the related function that it provides.

About server address parameters We do not need handwriting, connection has provided a getendpoints function that can be called directly

Stackexchange.redis Study Notes (iii) database and password configuration getserver function

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.