Unlock instant, AI-driven research and patent intelligence for your innovation.

Automatic data caching method and system based on redis

A data caching and caching technology, which is applied in the computer field, can solve problems such as inability to obtain the latest data from query statements, affect business, and the appearance of dirty data, so as to improve the efficiency and quality of data caching, query efficiency, and development efficiency.

Inactive Publication Date: 2021-03-16
福建福讯人才服务有限公司
View PDF5 Cites 0 Cited by
  • Summary
  • Abstract
  • Description
  • Claims
  • Application Information

AI Technical Summary

Problems solved by technology

Although the first method has the highest reading efficiency, it occupies a large amount of memory, and in a distributed scenario, it will cause dirty data and affect the business; the second method can only manually maintain the key (cache name) and value (cache) by operating redisTemplate content), and then cache the data. For a large number of database business read operations at the back end, the efficiency is extremely low and the error rate is high; for example, when different business modules use the same key, dirty data will appear. Lead to data coverage; in business development, queries, updates, and deletions will appear in multiple places. When the developer forgets to clear the cache after updating somewhere, the query statement will not be able to obtain the latest data, which will cause dirty data

Method used

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
View more

Image

Smart Image Click on the blue labels to locate them in the text.
Viewing Examples
Smart Image
  • Automatic data caching method and system based on redis
  • Automatic data caching method and system based on redis

Examples

Experimental program
Comparison scheme
Effect test

Embodiment Construction

[0038] Please refer to Figure 1 to Figure 2 As shown, a preferred embodiment of a redis-based automatic data caching method of the present invention includes the following steps:

[0039] Step S10, use mybatis as the persistence layer; inherit the ServiceImpl class in the business layer (such as UserService and UserServiceImpl), and set the annotation of the ServiceImpl class; the annotation includes starting the cache (CacheEnable) and clearing the cache (CacheClear); during specific implementation, It also inherits the IService interface to realize the paging function; annotation (Annotation), also known as Java annotation, is an annotation mechanism introduced by JDK5.0, and classes, methods, variables, parameters, and packages in the Java language can be annotated;

[0040] Step S20, setting the cache name generation strategy (ServiceKeyGenerator) for starting the cache and clearing the cache;

[0041] Step S30, when calling the query method or the addition, deletion and...

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
Login to View More

PUM

No PUM Login to View More

Abstract

The invention provides an automatic data caching method and system based on redis in the technical field of computers, and the method comprises the following steps: S10, inheriting a ServiceImpl classin a business layer, and setting an annotation of the ServiceImpl class, wherein the annotation comprises cache starting and cache clearing; s20, setting a cache name generation strategy for startingthe cache and clearing the cache; s30, when a query method or an addition, deletion and modification method is called through a ServiceImpl class, automatically generating a cache name by utilizing the cache name generation strategy, and generating cache content by utilizing a return value of the query method or the addition, deletion and modification method; and step S40, carrying out automaticcaching operation on the data based on the caching name and the caching content. The invention has the advantage that the data caching efficiency and quality are greatly improved.

Description

technical field [0001] The invention relates to the field of computer technology, in particular to a redis-based automatic data caching method and system. Background technique [0002] There are two existing data caching methods, one is to directly cache data in computer memory, and the other is to cache data through middleware, such as redis. Although the first method has the highest reading efficiency, it occupies a large amount of memory, and in a distributed scenario, it will cause dirty data and affect the business; the second method can only manually maintain the key (cache name) and value (cache) by operating redisTemplate content), and then cache the data. For a large number of database business read operations at the back end, the efficiency is extremely low and the error rate is high; for example, when different business modules use the same key, dirty data will appear. It leads to data overwriting; in business development, queries, updates, and deletions will app...

Claims

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
Login to View More

Application Information

Patent Timeline
no application Login to View More
Patent Type & Authority Applications(China)
IPC IPC(8): G06F16/2455G06F9/448
CPCG06F16/24552G06F9/449
Inventor 付军闫超黄海松潘晓莹
Owner 福建福讯人才服务有限公司