Redis Cache in Java

Source: Internet
Author: User
Tags connection pooling

1: Installation

Installation can be divided into single-version Redis and cluster version of Redis installation is relatively simple, self-Baidu can

2: Integration

Pom file with Jedis dependencies, Spring creates Redis's application-resid configuration, which configures Redis's standalone and cluster configurations separately, noting the need for connection pooling

3: Writing the DAO layer

Because of the need to be compatible with the standalone and cluster version, write the interface, respectively, to achieve the Redis single-and cluster-version implementation, which contains the common method of set get

4: Integrated Query service

(1) According to the configuration file configuration key read cache, if the cache exists, string to specific types such as list directly return

(2) cache does not exist, operation database, read data

(3) Store the key value into the cache

5: Sync Cache

DAO in the addition of the method of deleting the cache, you find that no, delete is actually synchronous

The synchronization service is written separately, when the business module data changes (insert or update), call the synchronous method, in fact, is deleted, in the query, naturally synchronized

Redis Cache in Java

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.