2020 March 24 redis face questions Redis record five data types and scenarios

--------------- Redis five data types and application scenarios --------------------------- ------

String: General cache do some complicated counting function of the
List: do simple message queue functions
Hash: Single Sign
Set: Global functions to do heavy
SortedSet: do chart application, take TopN operation; delay task; do range seek

 

 ------------------------------------ redis distributed lock --------- redis distributed transaction ----------------------------------------

https://blog.csdn.net/chanllenge/article/details/102983597?depth_1-utm_source=distribute.pc_relevant.none-task&utm_source=distribute.pc_relevant.none-task

What distributed transactions:

Multiple services at the same time modify records, to ensure data consistency.

Distributed ideas:

  1. By setting a single lock redis, if there is key, it is believed there are other clients in use, waiting for the lock release.
  2. If the key is not present, indicating that no client is using, you can perform the task is finished, unlock, delete key.
  3. Problems 1:

    After acquiring the lock, service downtime, because the key is unique, it can not be deleted.

    Problem 1 Solution

    Set an expiration time.

    Question 2 exists

    Task execution is too long, more than the expiration time.

    Problem 2 Solution

    By a daemon thread to thread continued life.

    3 problems:

    Task execution caused by an infinite loop, creating an infinite continued life.

    Question 3 Solution:

    Sets the maximum time continued life.

Guess you like

Origin www.cnblogs.com/weigy/p/12560455.html