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