CN115269660A - Cache data processing method and device, electronic equipment and storage medium - Google Patents

Cache data processing method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN115269660A
CN115269660A CN202211170652.0A CN202211170652A CN115269660A CN 115269660 A CN115269660 A CN 115269660A CN 202211170652 A CN202211170652 A CN 202211170652A CN 115269660 A CN115269660 A CN 115269660A
Authority
CN
China
Prior art keywords
cache
data
reading
subclass
service
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202211170652.0A
Other languages
Chinese (zh)
Inventor
卢衍佑
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Ping An Bank Co Ltd
Original Assignee
Ping An Bank Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Ping An Bank Co Ltd filed Critical Ping An Bank Co Ltd
Priority to CN202211170652.0A priority Critical patent/CN115269660A/en
Publication of CN115269660A publication Critical patent/CN115269660A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/245Query processing
    • G06F16/2455Query execution
    • G06F16/24552Database cache management
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/23Updating
    • G06F16/2379Updates performed during online database operations; commit processing
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/31Programming languages or programming paradigms
    • G06F8/315Object-oriented languages

Abstract

The invention discloses a cache data processing method and device, electronic equipment and a storage medium. The cache data processing method comprises the following steps: firstly, creating a cache service interface; then creating a cache service implementation parent, wherein the cache service implementation parent comprises a data reading method and a cache setting method, the data reading method is used for reading and writing cache data in a cache unit, and the cache setting method is used for reading and writing the data on the cache unit, or reading and writing the data from a database into the cache unit when the cache unit does not have the cache data; then when the reading of the cache data is realized, a cache service realization subclass is established, and the cache service realization subclass inherits the cache service realization parent class; and finally, calling a cache service to realize a data reading method of the subclass through a cache service interface so as to read the cache unit to cache data and generate new data. According to the technical scheme, the method and the device can effectively improve the reading and writing processing rapidity and stability of the cache data.

Description

Cache data processing method and device, electronic equipment and storage medium
Technical Field
The invention relates to the technical field of computer software, in particular to a cache data processing method and device, electronic equipment and a storage medium.
Background
Under the background of the digital era, more and more offline services in the field of financial science and technology are moved online, the digitization transformation becomes the key task of each enterprise at present, in order to reduce the response time of a user for accessing a system, the caching technology becomes an important technical means, in order to respond to a user request more quickly, hot data, configuration data, metadata and the like are cached, and the request to low-speed equipment is reduced.
In this process, how to improve the rapidity and stability of the read-write processing of the cache data is a problem to be solved urgently.
Disclosure of Invention
In order to overcome the above problems and defects, the present invention provides a method and an apparatus for processing cache data, an electronic device, and a storage medium, which can improve the rapidity and stability of the read/write processing of the cache data.
In order to achieve the above object, a first aspect of the present invention provides a cache data processing method, including:
creating a cache service interface;
creating a cache service implementation parent, wherein the cache service implementation parent comprises a data reading method and a cache setting method, the data reading method is used for reading cache data in a cache unit, and the cache setting method is used for reading and writing the data on the cache unit, or reading the data from a database and writing the data into the cache unit when the cache unit does not have the cache data;
when the reading of the cache data is realized, a cache service realization subclass is established, and the cache service realization subclass inherits the cache service realization parent class;
and calling the cache service to realize a data reading method of the subclass through the cache service interface so as to read the cache unit to cache data and generate new data.
A second aspect of the present invention provides a cache data processing apparatus, including:
the first establishing module is used for establishing a cache service interface;
the second creating module is used for creating a cache service implementation parent class, the cache service implementation parent class comprises a data reading method and a cache setting method, the data reading method is used for reading and writing cache data in the cache unit, and the cache setting method is used for reading and writing the data on the cache unit or reading and writing the data from the database into the cache unit when the cache unit does not have the cache data;
the third establishing module is used for establishing a cache service realization subclass when the cache data reading is realized, and the cache service realization subclass inherits the cache service realization parent class;
and the calling module is used for calling the cache service to realize a data reading method of the subclass through the cache service interface so as to read the cache unit to cache data and generate new data.
A third aspect of the present invention provides an electronic device, which includes a processor and a memory, where the memory stores a computer program, and the computer program, when executed by the processor, implements the above-mentioned cache data processing method.
A fourth aspect of the present invention provides a computer-readable storage medium on which a computer program is stored, the computer program, when executed by a processor, implementing the above-described cache data processing method.
Compared with the prior art, the invention has the beneficial effects that: firstly, creating a cache service interface; then creating a cache service implementation parent, wherein the cache service implementation parent comprises a data reading method and a cache setting method, the data reading method is used for reading and writing cache data in a cache unit, and the cache setting method is used for reading and writing the data on the cache unit, or reading and writing the data from a database into the cache unit when the cache unit does not have the cache data; then when the reading of the cache data is realized, a cache service realization subclass is established, and the cache service realization subclass inherits the cache service realization parent class; and finally, calling a cache service to realize a data reading method of the subclass through a cache service interface so as to read the cache unit to cache data and generate new data. According to the technical scheme, a inheritable parent class is created, so that the read-write operation for using the cache data is quickly realized, and the writing of new cache read-write logic is realized at lower cost. Moreover, codes are concentrated in the father class, stability of system quality is guaranteed, errors are not prone to occurring, and the rapidness and stability of reading and writing processing of cache data are effectively improved.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the invention and together with the description, serve to explain the principles of the invention. It is obvious that the drawings in the following description are only some embodiments of the invention, and that for a person skilled in the art, other drawings can be derived from them without inventive effort. In the drawings:
FIG. 1 is a schematic diagram of an exemplary system architecture for aspects of the present invention;
FIG. 2 is a flowchart illustrating a first step of a method for processing cache data according to an embodiment of the present invention;
FIG. 3 is a flowchart illustrating a second step of a method for processing cache data according to an embodiment of the present invention;
FIG. 4 is a block diagram of a cache data processing apparatus according to an embodiment of the present invention;
fig. 5 is a schematic diagram of a computer system of an electronic device according to an embodiment of the present invention.
Detailed Description
Example embodiments will now be described more fully with reference to the accompanying drawings. Example embodiments may, however, be embodied in many different forms and should not be construed as limited to the examples set forth herein; rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the concept of example embodiments to those skilled in the art.
Furthermore, the described features, structures, or characteristics may be combined in any suitable manner in one or more embodiments. In the following description, numerous specific details are provided to give a thorough understanding of embodiments of the invention. One skilled in the relevant art will recognize, however, that the invention may be practiced without one or more of the specific details, or with other methods, components, devices, steps, and so forth. In other instances, well-known methods, devices, implementations or operations have not been shown or described in detail to avoid obscuring aspects of the invention.
The block diagrams shown in the figures are functional entities only and do not necessarily correspond to physically separate entities. I.e. these functional entities may be implemented in the form of software, or in one or more hardware modules or integrated circuits, or in different networks and/or processor means and/or microcontroller means.
The flow charts shown in the drawings are merely illustrative and do not necessarily include all of the contents and operations/steps, nor do they necessarily have to be performed in the order described. For example, some operations/steps may be decomposed, and some operations/steps may be combined or partially combined, so that the actual execution sequence may be changed according to the actual situation.
Fig. 1 shows a schematic diagram of an exemplary system architecture to which the technical solution of the embodiments of the present invention can be applied.
As shown in fig. 1, the system architecture may include a terminal device (e.g., one or more of a smartphone 101, a tablet computer 102, and a portable computer 103 shown in fig. 1, and of course a desktop computer, etc.), a network 104, and a server 105. Network 104 is the medium used to provide communication links between terminal devices and server 105. Network 104 may include various connection types such as wired communication links, wireless communication links, and the like.
It should be understood that the number of terminal devices, networks, and servers in fig. 1 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for an implementation. For example, server 105 may be a server cluster comprised of multiple servers, and the like.
It should be noted that, the cache data processing method provided by the embodiment of the present invention is generally executed by the server 105, and accordingly, the cache data processing apparatus is generally disposed in the server 105. However, in other embodiments of the present invention, the terminal device may also have a function similar to that of the server, so as to execute the technical solution of the cache data processing provided by the embodiment of the present invention.
Details of implementation of the technical solution of the embodiment of the present invention are set forth in detail below.
An embodiment of the present invention provides a method for processing cache data, as shown in fig. 2, including step 201, step 202, step 203, and step 204, which are specifically as follows:
step 201, creating a cache service interface. Wherein, the cache service interface can be defined as CasheService < K >.
Step 202, a cache service implementation parent class is created, and includes a data reading method and a cache setting method, where the data reading method is used to perform cache data reading operation in the cache unit, and the cache setting method is used to read and write data on the cache unit, or when there is no cache data on the cache unit, read data from the database and write the data into the cache unit.
In this embodiment, the caching service implementation parent class may be an abstract parent class, and may be defined as BaseLocalCacheServiceImpl < K >.
Step 203, when the reading of the cache data is realized, a cache service realization subclass is created, and the cache service realization subclass inherits the cache service realization parent class.
Step 204, calling the cache service to realize a data reading method of the subclass through the cache service interface so as to read the cache unit to cache data and generate new data.
According to the method, a inheritable parent class is created, so that the read-write operation used by the cache data is realized quickly, and the writing of a new cache read-write logic is realized at a lower cost. Moreover, the codes are concentrated in the father class, so that the stability of the system quality is guaranteed, errors are not easy to occur, and the rapidness and the stability of the read-write processing of the cache data are effectively improved.
This embodiment can be applied. Features of generic inheritance in Java. Java generic (genetics) is a new feature introduced in JDK5, which provides a compile-time type security detection mechanism that allows programmers to detect illegal types at compile-time. The nature of the generic type is a parameterized type, i.e., a parameter is assigned to a type, and then a specific value of the parameter is assigned when the type is used, so that the type can be determined when the type is used. Such parameter types may be used in classes, interfaces, and methods, referred to as generic classes, generic interfaces, generic methods, respectively.
In one embodiment, step 202 may be exemplified by LoadingCache in Guava:
in the cache service implementation father, the data reading method is a read method of BaseLocalCacheServiceImpl, and the cache setting method is a SetCache () method.
In the SetCache () method, setting the expiration time and the upper limit of the content quantity of the Cache, calling an abstract method readDataFromDataBase to acquire data and filling the data into the Cache when the data is not found in the Cache.
Guava is a set of core Java libraries from Google, including new collection types (e.g., multimap and multiset), immutable collections, galleries, and utilities for concurrency, I/O, hashing, caching, primitives, strings! It is widely used for most Java projects inside Google, and is also widely used by many other companies.
The advantages of Guava include: standardized, the Guava library is hosted by google. The Java standard library is efficiently, reliably, quickly and effectively expanded. Optimization, the Guava library was highly optimized. Functional programming, increasing Java function and processing power. Utilities, provide many classes of utilities that often need to be developed at the application. And (4) verifying, wherein a standard fail-safe verification mechanism is provided. Best practice, emphasizing best practices.
In one embodiment, the cache setting method is further used for setting the expiration time and the maximum content amount of the cache data. Thus, the normal working performance of the cache can be ensured.
Wherein the expiration time ranges from 3000 seconds to 6000 seconds. This embodiment may be preferably 3600 seconds. For example, calling the SetCache () method sets the expiration time of data written into the cache to be 3600 seconds, and after the expiration time exceeds 3600 seconds, the cache data is removed, so as to avoid that the backlog of the cache data in the cache unit is too much and the maximum load of the cache is exceeded.
The maximum content amount ranges from 2000 items to 4000 items. This embodiment may preferably be 3000 items. For example, calling the SetCache () method sets the maximum capacity of a cache unit to 3000 entries, and when the cache data on the cache unit exceeds 3000 entries, the cache entries are removed according to the LRU (Least Recently Used) algorithm.
In an embodiment, the step of creating the cache service implementation subclass further includes, as shown in fig. 3:
step 2031, specify the key type of the cache service implementation subclass. For example, the key type (i.e., the K type) is designated as String.
Step 2032, reading the data object by the abstract method of reading data from the database, and writing the data object into the cache unit. The abstract method for reading data from a database may be defined as readDataFromDataBase.
In one embodiment, after the step of calling the cache service to implement the data reading method of the subclass, the method further includes: and setting the names of all variables in the data reading method.
The functions realized by the methods can be ensured by the method.
The steps and implementation codes of the cache data processing method of the embodiment are as follows:
1. interface CasheService < K > is defined:
public interface CacheService<K> {
K read(K keyDto);
void write(K dto, int expiredTime);
}。
2. defining an abstract parent class baselocalcache serviceimpl < K >:
public abstract class BaseLocalCacheServiceImpl<K> implements CacheService<K>, RefreshCache {
protected Logger logger = LoggerFactory.getLogger(getClass());
@SuppressWarnings("unchecked")
public K read(K keyDto) {
LogMap logMap = new Detector3(logger, "ma-pm-stock.cacheService");
String key = JSON.toJSONString(keyDto);
K dto;
logMap.add("key", key);
try {
//logger.info("read data in localCache - {}", logMap);
dto = this.getLocalCache().get(key);
dto = (K) JSON.parseObject(JSON.toJSONString(dto), getCacheObjectClass());
//logger.info("data return ={}", JSON.toJSON(dto));
} catch (Exception e) {
logMap.error("fail to read data from localCache & DB", e);
dto = null;
}
return dto;
}
/**
* LoadingCache object returning local
*
* @return
*/
public abstract LoadingCache<String, K> getLocalCache();
@SuppressWarnings("unchecked")
public LoadingCache<String, K> setCache() {
return CacheBuilder.newBuilder()
// set write cache 3600 seconds expired
.expireAfterWrite(Constant.DEFAULT_LOCAL_CACHE_EXPIREDTIME, TimeUnit.HOURS)
Setting the maximum cache size to 3000, over 3000 cache entries will be removed according to the LRU least recently used algorithm
.maximumSize(3000)
// set cache removal notification
.removalListener(new RemovalListener<Object, Object>() {
public void onRemoval(RemovalNotification<Object, Object> notification) {
logger.info(
notification.getKey() + " was removed, cause is " + notification.getCause());
}
})
The CacheLoader can be designated in the method// built, and when the cache does not exist, the cache is automatically loaded through the realization of the CacheLoader
.build(new CacheLoader<String, K>() {
@Override
public K load(String key) throws Exception {
logger.info("no data in local cache, select from oracle");
K keyDto = (K) JSON.parseObject(key, getCacheObjectClass());
return readDataFromDataBase(keyDto);
}
});
}
protected abstract Class getCacheObjectClass();
/**
* Returning a line of data captured in oracle
*
* @param keyDto
* @return
*/
public abstract K readDataFromDataBase(K keyDto);
@Override
public void write(K dto, int expiredTime) {
}
@Override
public void clearAllCache() {
if (this.getLocalCache() != null) {
this.getLocalCache().invalidateAll();
}
}
}。
3. The subclass inherits BaseLocalCacheServiceImpl, specifies a K type, such as String, and then realizes readDataFromDataBase;
@Service("mkCampaignPrizeCacheService")
public class MkCampaignPrizeCacheService extends BaseLocalCacheServiceImpl<String> {
protected Logger logger = LoggerFactory.getLogger(getClass());
private LoadingCache<String, String> localCache = setCache();
@Autowired
private CampaignDao campaignDao;
@Override
public String readDataFromDataBase(String idMkPrize) {
try {
if (StringUtils.isEmpty(idMkPrize)) {
throw new PafaRuntimeException(ResponseEnum.CAMPAIGN_ID_EMPTY);
}
List<String> camIdList = campaignDao.queryCadIdListByPrizeId(idMkPrize);
return CollectionUtils.isEmpty(camIdList) "" : camIdList.get(0);
} catch (Exception e) {
logger.error("readDataFromDB ", e);
throw new PafaRuntimeException(ResponseEnum.CAMPAIGN_QUERY_PRIZE_ERR);
}
}
@Override
public LoadingCache<String, String> getLocalCache() {
return localCache;
}
@Override
protected Class getCacheObjectClass() {
return String.class;
}
4. finally, when in use, cacheSerie is used, the variable name is specified, and the read method is called:
@Autowired
private CacheService mkCampaignPrizeCacheService;
mkCampaignPrizeCacheService.read(orderDto.getIdMkPrize())。
in this embodiment, by using the above method steps and codes, a cache service interface is first created; then creating a cache service implementation parent, wherein the cache service implementation parent comprises a data reading method and a cache setting method, the data reading method is used for reading cache data in a cache unit, and the cache setting method is used for reading and writing the data on the cache unit, or reading the data from a database and writing the data into the cache unit when the cache unit does not have the cache data; then when the reading of the cache data is realized, a cache service realization subclass is established, and the cache service realization subclass inherits the cache service realization parent class; and finally, calling a cache service to realize a data reading method of the subclass through a cache service interface so as to read the cache unit to cache data and generate new data.
By the cache data processing method of the embodiment, when the cache data is used, the cache is read first, if the cache is not found, the database is read, the data acquired from the database is written into the cache, and the expiration time is set so as to be convenient for use in the next reading.
According to the technical scheme, a inheritable parent class is created, so that the read-write operation used by the cache data is quickly realized, and the writing of new cache read-write logic is realized at lower cost. Moreover, codes are concentrated in the father class, stability of system quality is guaranteed, errors are not prone to occurring, and the rapidness and stability of reading and writing processing of cache data are effectively improved.
An embodiment of the present invention provides a cache data processing apparatus, as shown in fig. 4, including:
a first creating module 301, configured to create a cache service interface;
a second creating module 302, configured to create a cache service implementation parent class, where the cache service implementation parent class includes a data reading method and a cache setting method, the data reading method is used to perform a cache data reading operation in a cache unit, and the cache setting method is used to read and write data on the cache unit, or read and write data from a database into the cache unit when there is no cache data on the cache unit;
a third creating module 303, configured to create a caching service implementation subclass when reading of the cached data is implemented, where the caching service implementation subclass inherits a caching service implementation parent class;
the calling module 304 is configured to call the cache service to implement a data reading method of the subclass through the cache service interface, so as to read the cache unit to perform cache data, and generate new data.
The cache data processing apparatus of this embodiment uses the cache data processing method provided in the above embodiment to create a inheritable parent class, so as to quickly implement read-write operation for use of cache data, and implement writing of new cache read-write logic at a lower cost. Moreover, codes are concentrated in the father class, stability of system quality is guaranteed, errors are not prone to occurring, and the rapidness and stability of reading and writing processing of cache data are effectively improved.
In this embodiment, the cache setting method is further configured to set an expiration time and a maximum content amount of the cache data. Thus, the normal working performance of the cache can be ensured.
Wherein, the value range of the expiration time is 3000 seconds to 6000 seconds. This embodiment may preferably be 3600 seconds. For example, calling the SetCache () method sets the expiration time of data written into the cache to be 3600 seconds, and after the expiration time exceeds 3600 seconds, the cache data is removed, so as to avoid that the backlog of the cache data in the cache unit is too much and the maximum load of the cache is exceeded.
The maximum content quantity has a value ranging from 2000 items to 4000 items. This embodiment may preferably be 3000 items. For example, calling the SetCache () method sets the maximum capacity of a cache unit to 3000 entries, and when the cache data on the cache unit exceeds 3000 entries, the cache entry is removed according to the LRU (Least Recently Used) algorithm.
Through the cache data processing device of the embodiment, a cache service interface is firstly established; then creating a cache service implementation parent, wherein the cache service implementation parent comprises a data reading method and a cache setting method, the data reading method is used for reading and writing cache data in a cache unit, and the cache setting method is used for reading and writing the data on the cache unit, or reading and writing the data from a database into the cache unit when the cache unit does not have the cache data; then when the reading of the cache data is realized, a cache service realization subclass is established, and the cache service realization subclass inherits the cache service realization parent class; and finally, calling a cache service to realize a data reading method of the subclass through a cache service interface so as to read the cache unit to cache data and generate new data.
The cache data of the embodiment can create a inheritable parent class to quickly realize the read-write operation used by the cache data and write a new cache read-write logic with lower cost. Moreover, the codes are concentrated in the father class, so that the stability of the system quality is guaranteed, errors are not easy to occur, and the rapidness and the stability of the read-write processing of the cache data are effectively improved.
FIG. 5 illustrates a schematic structural diagram of a computer system suitable for use with the electronic device to implement an embodiment of the invention.
It should be noted that the computer system of the electronic device shown in fig. 5 is only an example, and should not bring any limitation to the function and the scope of the application of the embodiment of the present invention.
As shown in fig. 5, the computer system includes a Central Processing Unit (CPU) 1801, which can perform various appropriate actions and processes, such as executing the method described in the above embodiments, according to a program stored in a Read-Only Memory (ROM) 1802 or a program loaded from a storage portion 1808 into a Random Access Memory (RAM) 1803. In the RAM 1803, various programs and data necessary for system operation are also stored. The CPU 1801, ROM 1802, and RAM 1803 are connected to each other via a bus 1804. An Input/Output (I/O) interface 1805 is also connected to bus 1804.
The following components are connected to the I/O interface 1805: an input portion 1806 including a keyboard, a mouse, and the like; an output section 1807 including a Display such as a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and a speaker; a storage portion 1808 including a hard disk and the like; and a communication section 1809 including a Network interface card such as a LAN (Local Area Network) card, a modem, or the like. The communication section 1809 performs communication processing via a network such as the internet. A driver 1810 is also connected to the I/O interface 1805 as necessary. A removable medium 1811 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 1810 as necessary, so that a computer program read out therefrom is mounted in the storage portion 1808 as necessary.
In particular, the processes described above with reference to the flowcharts may be implemented as a computer software program according to an embodiment of the present invention. For example, embodiments of the invention include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising a computer program for performing the method illustrated in the flow chart. In such embodiments, the computer program may be downloaded and installed from a network via the communication portion 1809, and/or installed from the removable media 1811. The computer program executes various functions defined in the system of the present invention when executed by a Central Processing Unit (CPU) 1801.
It should be noted that the computer readable medium shown in the embodiment of the present invention may be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a Read-Only Memory (ROM), an Erasable Programmable Read-Only Memory (EPROM), a flash Memory, an optical fiber, a portable Compact Disc Read-Only Memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present invention, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In contrast, in the present invention, a computer-readable signal medium may include a propagated data signal with a computer program embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. The computer program embodied on the computer readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wired, etc., or any suitable combination of the foregoing.
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present invention. Each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams or flowchart illustration, and combinations of blocks in the block diagrams or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The units described in the embodiments of the present invention may be implemented by software, or may be implemented by hardware, and the described units may also be disposed in a processor. Wherein the names of the elements do not in some way constitute a limitation on the elements themselves.
Specifically, with the electronic device of the embodiment, a cache service interface is first created; then creating a cache service implementation parent, wherein the cache service implementation parent comprises a data reading method and a cache setting method, the data reading method is used for reading and writing cache data in a cache unit, and the cache setting method is used for reading and writing the data on the cache unit, or reading and writing the data from a database into the cache unit when the cache unit does not have the cache data; then when the reading of the cache data is realized, a cache service realization subclass is established, and the cache service realization subclass inherits the cache service realization parent class; and finally, calling a cache service to realize a data reading method of the subclass through a cache service interface so as to read the cache unit to cache data and generate new data. The electronic equipment can create a sustainable father class to quickly realize the read-write operation for using the cache data and write a new cache read-write logic with lower cost. Moreover, codes are concentrated in the father class, stability of system quality is guaranteed, errors are not prone to occurring, and the rapidness and stability of reading and writing processing of cache data are effectively improved.
As another aspect, the present invention also provides a computer-readable storage medium, which may be contained in the electronic device described in the above embodiments; or may exist separately without being assembled into the electronic device. The storage medium carries one or more programs, and when the one or more programs are executed by the electronic device, the electronic device is enabled to implement the method provided in the above embodiment.
It should be noted that although in the above detailed description several modules or units of the device for action execution are mentioned, such a division is not mandatory. Indeed, the features and functionality of two or more modules or units described above may be embodied in one module or unit, according to embodiments of the invention. Conversely, the features and functions of one module or unit described above may be further divided into embodiments by a plurality of modules or units.
Through the above description of the embodiments, those skilled in the art will readily understand that the exemplary embodiments described herein may be implemented by software, or by software in combination with necessary hardware. Therefore, the technical solution according to the embodiment of the present invention can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a usb disk, a removable hard disk, etc.) or on a network, and includes several instructions to enable a computing device (which can be a personal computer, a server, a touch terminal, or a network device, etc.) to execute the method according to the embodiment of the present invention.
Specifically, with the storage medium of this embodiment, a cache service interface is created first; then creating a cache service implementation parent, wherein the cache service implementation parent comprises a data reading method and a cache setting method, the data reading method is used for reading and writing cache data in a cache unit, and the cache setting method is used for reading and writing the data on the cache unit, or reading and writing the data from a database into the cache unit when the cache unit does not have the cache data; then when the reading of the cache data is realized, a cache service realization subclass is established, and the cache service realization subclass inherits the cache service realization parent class; and finally, calling cache service to realize a data reading method of subclasses through a cache service interface so as to read cache units to cache data and generate new data. According to the storage medium of the embodiment, by the technical scheme, a inheritable parent class is created, so that the read-write operation for using the cache data is quickly realized, and the writing of a new cache read-write logic is realized at a lower cost. Moreover, the codes are concentrated in the father class, so that the stability of the system quality is guaranteed, errors are not easy to occur, and the rapidness and the stability of the read-write processing of the cache data are effectively improved.
Other embodiments of the invention will be apparent to those skilled in the art from consideration of the specification and practice of the embodiments disclosed herein. This invention is intended to cover any variations, uses, or adaptations of the invention following, in general, the principles of the invention and including such departures from the present disclosure as come within known or customary practice within the art to which the invention pertains.
It will be understood that the invention is not limited to the precise arrangements described above and shown in the drawings and that various modifications and changes may be made without departing from the scope thereof. The scope of the invention is limited only by the appended claims.

Claims (10)

1. A method for processing cache data, comprising:
creating a cache service interface;
creating a cache service implementation parent class, wherein the cache service implementation parent class comprises a data reading method and a cache setting method, the data reading method is used for reading cache data in a cache unit, and the cache setting method is used for reading and writing the data on the cache unit, or reading the data from a database and writing the data into the cache unit when no cache data exists on the cache unit;
when the reading of the cache data is realized, a cache service realization subclass is established, and the cache service realization subclass inherits the cache service realization parent class;
and calling the cache service to realize the data reading method of the subclass through the cache service interface so as to read the cache unit for caching data and generate new data.
2. The cache data processing method according to claim 1, wherein the cache setting method is further configured to set an expiration time and a maximum content amount of the cache data.
3. The method according to claim 2, wherein the expiration time is in a range of 3000 seconds to 6000 seconds.
4. The method according to claim 2, wherein the maximum content amount has a value in a range of 2000 entries to 4000 entries.
5. The method for processing cache data according to claim 1, wherein the step of creating the cache service implementation subclass further comprises:
specifying a key type of a cache service implementation subclass;
and reading the data object by an abstract method of reading data from a database, and writing the data object into the cache unit.
6. The method for processing cached data according to claim 1, further comprising, after said step of invoking said data read method of said caching service implementation subclass:
and setting the name of each variable in the data reading method.
7. A cache data processing apparatus, comprising:
the first establishing module is used for establishing a cache service interface;
a second creating module, configured to create a cache service implementation parent class, where the cache service implementation parent class includes a data reading method and a cache setting method, the data reading method is used to perform a cache data reading operation in a cache unit, and the cache setting method is used to read and write data on the cache unit, or read data from a database and write the data into the cache unit when there is no cache data on the cache unit;
the third establishing module is used for establishing a cache service realization subclass when the cache data reading is realized, wherein the cache service realization subclass inherits the cache service realization parent class;
and the calling module is used for calling the cache service to realize the data reading method of the subclass through the cache service interface so as to read the cache unit to cache data and generate new data.
8. The cache data processing apparatus according to claim 7, wherein the cache setting method is further configured to set an expiration time and a maximum content amount of the cache data.
9. An electronic device comprising a processor and a memory, the memory having stored thereon a computer program that, when executed by the processor, implements the cache data processing method of any one of claims 1 to 6.
10. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, implements the cache data processing method according to any one of claims 1 to 6.
CN202211170652.0A 2022-09-26 2022-09-26 Cache data processing method and device, electronic equipment and storage medium Pending CN115269660A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211170652.0A CN115269660A (en) 2022-09-26 2022-09-26 Cache data processing method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211170652.0A CN115269660A (en) 2022-09-26 2022-09-26 Cache data processing method and device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN115269660A true CN115269660A (en) 2022-11-01

Family

ID=83756905

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211170652.0A Pending CN115269660A (en) 2022-09-26 2022-09-26 Cache data processing method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN115269660A (en)

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1329300A (en) * 2000-06-21 2002-01-02 国际商业机器公司 Management speech buffer storage method
US20130111144A1 (en) * 2011-10-28 2013-05-02 International Business Machines Corporation Efficient memory management in software caches
CN106484633A (en) * 2016-10-08 2017-03-08 广州华多网络科技有限公司 A kind of data cached method and device
CN109240613A (en) * 2018-08-29 2019-01-18 平安科技(深圳)有限公司 Data cache method, device, computer equipment and storage medium
CN111400350A (en) * 2020-03-13 2020-07-10 上海携程商务有限公司 Configuration data reading method, system, electronic device and storage medium
CN112783656A (en) * 2021-01-29 2021-05-11 网易(杭州)网络有限公司 Memory management method, medium, device and computing equipment
CN114780565A (en) * 2022-04-24 2022-07-22 青岛海尔科技有限公司 Cache updating method and device, storage medium and electronic device
CN115065366A (en) * 2022-06-08 2022-09-16 上海达梦数据库有限公司 Compression method, device and equipment of time sequence data and storage medium

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1329300A (en) * 2000-06-21 2002-01-02 国际商业机器公司 Management speech buffer storage method
US20130111144A1 (en) * 2011-10-28 2013-05-02 International Business Machines Corporation Efficient memory management in software caches
CN106484633A (en) * 2016-10-08 2017-03-08 广州华多网络科技有限公司 A kind of data cached method and device
CN109240613A (en) * 2018-08-29 2019-01-18 平安科技(深圳)有限公司 Data cache method, device, computer equipment and storage medium
CN111400350A (en) * 2020-03-13 2020-07-10 上海携程商务有限公司 Configuration data reading method, system, electronic device and storage medium
CN112783656A (en) * 2021-01-29 2021-05-11 网易(杭州)网络有限公司 Memory management method, medium, device and computing equipment
CN114780565A (en) * 2022-04-24 2022-07-22 青岛海尔科技有限公司 Cache updating method and device, storage medium and electronic device
CN115065366A (en) * 2022-06-08 2022-09-16 上海达梦数据库有限公司 Compression method, device and equipment of time sequence data and storage medium

Similar Documents

Publication Publication Date Title
US10437795B2 (en) Upgrading systems with changing constraints
US9069832B2 (en) Approach for modularized sychronization and memory management
US10339311B2 (en) Anomalous commit detection
US9477609B2 (en) Enhanced transactional cache with bulk operation
JP2006072986A (en) Verifying dynamically generated operations on data store
EP2797013A1 (en) Database update execution according to power management schemes
CN111427971B (en) Business modeling method, device, system and medium for computer system
US20230401241A1 (en) System for lightweight objects
US8458652B2 (en) Device, system and method of modeling homogeneous information
US20170039042A1 (en) Versioning for configurations of reusable artifacts
US10210199B2 (en) Dynamic master data management
US9442719B2 (en) Regression alerts
US10776364B1 (en) Processing streaming data in a transaction-based distributed database system
US20140136578A1 (en) Techniques to manage virtual files
CN113312259A (en) Interface testing method and device
US11106564B2 (en) Deframeworking for static program analysis
GB2559999A (en) Generic customizable navigation workflow and reporting systems for capturing mobile forms data
US20170322777A1 (en) Presentation Oriented Rules-based Technical Architecture Display Framework
US9009731B2 (en) Conversion of lightweight object to a heavyweight object
CN115758004A (en) Webpage table display method and device, computer readable medium and electronic equipment
CN115269660A (en) Cache data processing method and device, electronic equipment and storage medium
CN115543428A (en) Simulated data generation method and device based on strategy template
US11347533B2 (en) Enhanced virtual machine image management system
US9342541B1 (en) Presentation oriented rules-based technical architecture display framework (PORTRAY)
CN117573199B (en) Model difference comparison analysis method, device, equipment and medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication
RJ01 Rejection of invention patent application after publication

Application publication date: 20221101