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

By obtaining the information in the configuration file, determining whether to enable the cache dual write function and configure the cache middleware, the problem of inflexible cache data processing in the existing technology is solved, and the convenience and efficiency of cache switching is achieved.

CN119025564APending Publication Date: 2024-11-26CHINA CONSTRUCTION BANK +1
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202411166199.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-23
Publication Date
2024-11-26

AI Technical Summary

Technical Problem

In the prior art, cached data processing is not flexible enough, and it is difficult to realize cache switching, and fixed write cache middleware leads to inconvenient data processing.

Method used

By obtaining the information in the configuration file, we determine whether the cache double write function is enabled, and the first cache middleware is configured as the main cache middleware or the slave cache middleware according to the configuration file, so that the write and read of cached data can be realized, allowing Switch cache middleware without migrating data.

Benefits of technology

It improves the flexibility of cache data processing, simplifies the cache switching process, reduces the need for cache data migration, and supports personalized application scenarios and efficient cache switching.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119025564A_ABST
    Figure CN119025564A_ABST
Patent Text Reader

Abstract

The invention provides a cache data processing method and device, electronic equipment and a storage medium, and relates to the technical field of computers. The cache data processing method comprises the following steps: acquiring cache data; a configuration file is obtained, the configuration file comprises first information and second information, the first information is used for indicating whether a cache double-writing function is started or not, and the second information is used for indicating that the first cache middleware is configured as a main cache; under the condition that the first information indicates that the cache double-writing function is started, cache data are written into first cache middleware and second cache middleware, and the first cache middleware and the second cache middleware are different; and under the condition that the first information indicates that the cache double-writing function is not started, writing the cache data into the first cache middleware, and not writing the cache data into the second cache middleware. The technical problems that in the prior art, cache data processing is not flexible enough, and cache switching is inconvenient to achieve are solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of computer technology, and in particular to a cache data processing method, device, electronic device and storage medium. Background Art

[0002] Cache middleware, such as Coherence and Redis (Coherence is a middleware of Oracle, and its main purpose is to share an application object. Redis is an open source high-performance key-value storage system). Cache middleware can share the cache data (such as objects or data) of an application. When an application entrusts its cache data (such as objects or data) to cache middleware for management, the cache data can be shared in the entire cluster environment, and the application can call the get method to obtain the cache data.

[0003] In the related art, cache data is usually fixedly written into a cache middleware. In this way, cache data processing is not flexible enough and it is not convenient to implement cache switching. Summary of the invention

[0004] The present disclosure aims to solve one of the technical problems in the related art at least to some extent.

[0005] To this end, the first objective of the present disclosure is to propose a cache data processing method to improve the flexibility of cache data processing and facilitate cache switching.

[0006] A second objective of the present disclosure is to provide a cache data processing device.

[0007] A third objective of the present disclosure is to provide an electronic device.

[0008] A fourth objective of the present disclosure is to provide a computer-readable storage medium.

[0009] A fifth object of the present disclosure is to provide a computer program product.

[0010] To achieve the above-mentioned purpose, the first aspect embodiment of the present disclosure proposes a cache data processing method, including: obtaining cache data; obtaining a configuration file, wherein the configuration file includes first information and second information, the first information is used to indicate whether the cache double-write function is enabled, and the second information is used to indicate that the first cache middleware is configured as the main cache; when the first information indicates that the cache double-write function is enabled, writing cache data to the first cache middleware and the second cache middleware, wherein the first cache middleware and the second cache middleware are different; when the first information indicates that the cache double-write function is not enabled, writing cache data to the first cache middleware, and not writing cache data to the second cache middleware.

[0011] To achieve the above-mentioned purpose, the second aspect embodiment of the present disclosure proposes a cache data processing device, including: a first acquisition module, used to acquire cache data; a second acquisition module, used to acquire a configuration file, wherein the configuration file includes first information and second information, the first information is used to indicate whether the cache double-write function is enabled, and the second information is used to indicate that the first cache middleware is configured as the main cache; a processing module, used to write cache data to the first cache middleware and the second cache middleware when the first information indicates that the cache double-write function is enabled, wherein the first cache middleware and the second cache middleware are different, and when the first information indicates that the cache double-write function is not enabled, the cache data is written to the first cache middleware, and the cache data is not written to the second cache middleware.

[0012] To achieve the above-mentioned purpose, the third aspect embodiment of the present disclosure proposes an electronic device, comprising: a processor, and a memory communicatively connected to the processor; the memory stores computer execution instructions; the processor executes the computer execution instructions stored in the memory to implement a cache data processing method proposed in the first aspect embodiment of the present disclosure.

[0013] To achieve the above-mentioned purpose, the fourth aspect embodiment of the present disclosure proposes a computer-readable storage medium, in which computer execution instructions are stored. When the computer execution instructions are executed by the processor, they are used to implement a cache data processing method proposed in the first aspect embodiment of the present disclosure.

[0014] To achieve the above-mentioned purpose, the fifth aspect of the present disclosure proposes a computer program product, including a computer program, which, when executed by a processor, implements a cache data processing method proposed in the first aspect of the present disclosure.

[0015] The cache data processing method, device, electronic device, non-transitory computer-readable storage medium storing computer instructions, and computer program product provided by the present disclosure obtain cache data and a configuration file, wherein the configuration file includes first information and second information, the first information is used to indicate whether to enable the cache double-write function, and the second information is used to indicate that the first cache middleware is configured as the main cache, and when the first information indicates that the cache double-write function is enabled, cache data is written to the first cache middleware and the second cache middleware, wherein the first cache middleware and the second cache middleware are different. When switching is required, there is no need to migrate the cache data in different cache middlewares, and only the configuration file needs to be modified, thereby improving the flexibility of cache data processing and facilitating cache switching.

[0016] Additional aspects and advantages of the present disclosure will be given in part in the following description and in part will be obvious from the following description or learned through practice of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] The above and / or additional aspects and advantages of the present disclosure will become apparent and easily understood from the following description of the embodiments in conjunction with the accompanying drawings, in which:

[0018] Figure 1 A schematic diagram of a process flow of a cache data processing method provided by an embodiment of the present disclosure;

[0019] Figure 2 A flowchart of another cache data processing method provided by an embodiment of the present disclosure;

[0020] Figure 3 A flowchart of another cache data processing method provided by an embodiment of the present disclosure;

[0021] Figure 4 is a schematic diagram of a logic flow of determining a primary cache in an embodiment of the present disclosure;

[0022] Figure 5 is a logic flow chart of read cache and write cache in the embodiment of the present disclosure;

[0023] Fig. 6A This is a schematic diagram of the first stage implementation steps of switching from coherence to redis in the embodiment of the present disclosure;

[0024] Figure 6B This is a schematic diagram of the second stage implementation steps of switching from coherence to redis in the embodiment of the present disclosure;

[0025] Figure 6C It is a schematic diagram of the third stage implementation steps of switching from coherence to redis in the embodiment of the present disclosure;

[0026] Figure 7 A schematic diagram of the structure of a cache data processing device provided by an embodiment of the present disclosure;

[0027] Figure 8 It is a schematic structural diagram of an electronic device shown in an exemplary embodiment of the present disclosure. DETAILED DESCRIPTION

[0028] Embodiments of the present disclosure are described in detail below, and examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are intended to be used to explain the present disclosure, and should not be construed as limiting the present disclosure.

[0029] It should be noted that the information (including but not limited to user device information, user personal information, etc.), data (including but not limited to data used for analysis, stored data, displayed data, etc.) and signals involved in this disclosure are all authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of relevant countries and regions. The acquisition, transmission, storage, use and processing of data in the technical solution of this disclosure are in compliance with the relevant provisions of national laws and regulations.

[0030] It should be noted that in the embodiments of the present disclosure, certain software, components, models and other existing solutions in the industry may be mentioned, which should be regarded as exemplary. Their purpose is only to illustrate the feasibility of implementing the technical solution of the present disclosure, but it does not mean that the applicant has or will necessarily use the solution.

[0031] "Write" in the embodiments of the present disclosure refers to the add, delete, and modify operations during the operation of the cache middleware.

[0032] Figure 1 A schematic diagram of a flow chart of a cache data processing method provided in an embodiment of the present disclosure.

[0033] This embodiment takes the cache data processing method being configured in a cache data processing device as an example. In this embodiment, the cache data processing method can be configured in a cache data processing device. The cache data processing device can be set in a server, or can also be set in an electronic device, without limitation.

[0034] This embodiment takes the cache data processing method configured in an electronic device as an example, wherein the electronic device is a hardware device such as a smart phone, a tablet computer, a personal digital assistant, an e-book, etc. having various operating systems.

[0035] It should be noted that the execution subject of the embodiment of the present disclosure may be, for example, a central processing unit (CPU) in a server or electronic device in terms of hardware, or may be, for example, a related background service in a server or electronic device in terms of software, without limitation.

[0036] like Figure 1 As shown, the cache data processing method includes:

[0037] S101: Obtain cache data.

[0038] The cache data refers to the data to be cached of the application, such as the objects and / or data of the application. When the cache data is stored in the cache middleware, it can support sharing of the cache data in the cluster.

[0039] In some embodiments, objects and / or data of an application may be received as cache data based on a data interface; or cache data of the application may be read from a database; or cache data may be obtained based on any other possible method, without limitation.

[0040] S102: Obtain a configuration file, wherein the configuration file includes first information and second information, the first information is used to indicate whether to enable the cache dual-write function, and the second information is used to indicate to configure the first cache middleware as the main cache.

[0041] The configuration file may refer to a file used to configure whether to enable the cache double-write function and to configure the primary cache. The configuration file may include first information and second information, the first information being used to indicate whether to enable the cache double-write function, and the second information being used to indicate that the first cache middleware is configured as the primary cache. The cache middleware that is not configured as the primary cache may be referred to as a slave cache, a backup cache, etc., without limitation.

[0042] In some embodiments, the first information and the second information may be corresponding fields, and different values ​​may be used for the fields to configure the cache double write function to be enabled or disabled. Alternatively, different values ​​may be used for the fields to configure a cache middleware as the main cache.

[0043] The cache dual write function refers to the function of writing cache data to different cache middleware at the same time. The primary cache refers to the cache middleware that stores cache data first.

[0044] In some embodiments, the first information and / or the second information in the configuration file may be personalized based on actual application requirements to support personalized cache settings of the cache middleware.

[0045] In some embodiments, the above configuration file may be pre-set, or in the process of actually caching the cache data of the application, the existing configuration file may be personalized and modified, and there is no limitation on this.

[0046] After obtaining the cache data and the configuration file, the first information and the second information can be parsed from the configuration file, and whether to enable the cache double-write function is analyzed based on the first information, and which cache middleware is set as the primary cache is analyzed based on the second information.

[0047] In some embodiments, if the first information is initially configured to enable the cache double-write function, the first information may be dynamically updated so that the updated first information may be used to configure not to enable the cache double-write function.

[0048] In some embodiments, if the initial second information configures cache middleware A as the primary cache, the second information may be dynamically updated so that the updated second information may be used to configure cache middleware B as the primary cache.

[0049] In some embodiments, it may support configuring a cache middleware as a primary cache without limitation.

[0050] S103: When the first information indicates that the cache double-write function is enabled, write cache data to the first cache middleware and the second cache middleware, wherein the first cache middleware and the second cache middleware are different.

[0051] The first cache middleware is a cache middleware configured as a main cache. The second cache middleware is a cache middleware that is not configured as a main cache. The first cache middleware and the second cache middleware are different, which means that the types of the first cache middleware and the second cache middleware are different.

[0052] For example, the first cache middleware may be, for example, Coherence, and the second cache middleware may be, for example, Redis. Alternatively, the first cache middleware may be, for example, Redis, and the second cache middleware may be, for example, Coherence.

[0053] After obtaining the cache data and configuration file, the cache data can be written to the first cache middleware and the second cache middleware when the first information indicates that the cache double-write function is enabled. For example, the cache data can be written to the first cache middleware and the second cache middleware at the same time, or the cache data can be written to the first cache middleware first and then to the second cache middleware, without limitation.

[0054] Since whether to enable the cache dual-write function and which cache middleware is configured as the main cache are controlled on demand based on the configuration file, when switching is required, there is no need to migrate the cache data in different cache middlewares, only the configuration file needs to be modified, thereby improving the flexibility of cache data processing and facilitating cache switching.

[0055] S104: When the first information indicates that the cache dual-write function is not enabled, cache data is written to the first cache middleware, and cache data is not written to the second cache middleware.

[0056] In some embodiments of the present disclosure, after obtaining the cache data and the configuration file, when the first information indicates that the cache double-write function is not enabled, the cache data is written to the first cache middleware, but not to the second cache middleware. This further improves the flexibility of cache data processing and can support application in personalized application scenarios.

[0057] That is to say, if the configuration file does not enable the cache double-write function, and the second information configures the first cache middleware as the main cache, cache data can be written only to the first cache middleware configured as the main cache, without writing cache data to the second cache middleware.

[0058] In this embodiment, by obtaining cache data and a configuration file, wherein the configuration file includes first information and second information, the first information is used to indicate whether to enable the cache double-write function, and the second information is used to indicate that the first cache middleware is configured as the main cache, and when the first information indicates that the cache double-write function is enabled, cache data is written to the first cache middleware and the second cache middleware, wherein the first cache middleware and the second cache middleware are different. When switching is required, there is no need to migrate cache data in different cache middlewares, and only the configuration file needs to be modified, thereby improving the flexibility of cache data processing and facilitating cache switching.

[0059] In some embodiments of the present disclosure, after writing cache data to the first cache middleware and the second cache middleware, it is possible to detect whether the cache data is successfully written to the first cache middleware, and obtain a detection result. If the detection result indicates that the writing is successful, the writing result of the first cache middleware is returned, and if the detection result indicates that the writing is not successful, the writing result of the second cache middleware is returned. The returned writing result can support the cache data to be correctly read, so as to improve the accuracy of cache data processing.

[0060] Figure 2 A flowchart of another cache data processing method provided by an embodiment of the present disclosure.

[0061] like Figure 2 As shown, the cache data processing method includes:

[0062] S201: Obtain cache data.

[0063] S202: Obtain a configuration file, wherein the configuration file includes first information and second information, the first information is used to indicate whether to enable the cache dual-write function, and the second information is used to indicate to configure the first cache middleware as the main cache.

[0064] For the description of S201 - S202 , please refer to the above embodiment, which will not be repeated here.

[0065] S203: When the first information indicates that the cache double-write function is enabled, cache data is first written to the first cache middleware, and then the cache data is written to the second cache middleware, wherein the first cache middleware and the second cache middleware are different.

[0066] In some embodiments, when the first information indicates that the cache double-write function is enabled, cache data may be written to the first cache middleware first, and then to the second cache middleware. Since the first cache middleware is configured as the main cache, cache data may be written to the first cache middleware first, and then to the second cache middleware, to support the cache data in the first cache middleware configured as the main cache to be read in a timely manner.

[0067] S204: Make the first cache middleware and the second cache middleware meet the data consistency condition.

[0068] In some embodiments, during the process of writing cache data into each cache middleware, a consistency check can be performed on the cache data in the first cache middleware and the second cache middleware to determine whether the first cache middleware and the second cache middleware meet the data consistency condition. If not, any possible data consistency processing method is used to perform consistency processing on the cache data in the first cache middleware and the second cache middleware so that the first cache middleware and the second cache middleware meet the data consistency condition, thereby ensuring the correctness of the cached data during cache switching, and improving the accuracy of cache switching while supporting efficient cache switching.

[0069] S205: When the first information indicates that the cache double-write function is not enabled, the cache data is written to the first cache middleware, and the cache data is not written to the second cache middleware.

[0070] In some embodiments of the present disclosure, after obtaining the cache data and the configuration file, when the first information indicates that the cache double-write function is not enabled, the cache data is written to the first cache middleware, but not to the second cache middleware. This further improves the flexibility of cache data processing and can support application in personalized application scenarios.

[0071] That is to say, if the configuration file does not enable the cache double-write function, and the second information configures the first cache middleware as the main cache, cache data can be written only to the first cache middleware configured as the main cache, without writing cache data to the second cache middleware.

[0072] S206: Read cache data from the first cache middleware.

[0073] After the cache data is written into the first cache middleware, the cache data may be directly read from the first cache middleware configured as the primary cache.

[0074] In this embodiment, by obtaining cache data and a configuration file, wherein the configuration file includes first information and second information, the first information is used to indicate whether to enable the cache double-write function, and the second information is used to indicate that the first cache middleware is configured as the main cache, and when the first information indicates that the cache double-write function is enabled, cache data is written to the first cache middleware and the second cache middleware, wherein the first cache middleware and the second cache middleware are different. When switching is required, there is no need to migrate cache data in different cache middlewares, and only the configuration file needs to be modified, thereby improving the flexibility of cache data processing and facilitating cache switching. When the first information indicates that the cache double-write function is enabled, cache data can be written to the first cache middleware first, and then to the second cache middleware. Since the first cache middleware is configured as the main cache, cache data can be written to the first cache middleware first, and then to the second cache middleware, so as to support the cache data in the first cache middleware configured as the main cache to be read in a timely manner. In the process of writing cache data into each cache middleware, a consistency check can be performed on the cache data in the first cache middleware and the second cache middleware to determine whether the first cache middleware and the second cache middleware meet the data consistency condition. If not, any possible data consistency processing method is used to perform consistency processing on the cache data in the first cache middleware and the second cache middleware, so that the first cache middleware and the second cache middleware meet the data consistency condition, thereby ensuring that the correctness of the cached data can be ensured when the cache is switched, while supporting efficient cache switching, the accuracy of cache switching can also be improved. After obtaining the cache data and the configuration file, when the first information indicates that the cache double-write function is not enabled, the cache data is written to the first cache middleware, and the cache data is not written to the second cache middleware. This further improves the flexibility of cache data processing and can support application in personalized application scenarios.

[0075] Figure 3 A flowchart of another cache data processing method provided by an embodiment of the present disclosure.

[0076] like Figure 3 As shown, the cache data processing method includes:

[0077] S301: Obtain cache data.

[0078] S302: Obtain a configuration file, wherein the configuration file includes first information and second information, the first information is used to indicate whether to enable the cache dual-write function, and the second information is used to indicate to configure the first cache middleware as the main cache.

[0079] For the description of S301 - S302 , please refer to the above embodiment, which will not be repeated here.

[0080] S303: Combine the first cache client object and the second cache client object into a double-write implementation class object using the facade pattern, wherein the first cache client corresponds to the first cache middleware, and the second cache client corresponds to the second cache middleware.

[0081] S304: When the first information indicates that the cache double-write function is enabled, cache data is written to the first cache middleware and the second cache middleware through the double-write implementation class.

[0082] S305: When the first information indicates that the cache double-write function is not enabled, the cache data is written to the first cache middleware, and the cache data is not written to the second cache middleware.

[0083] In this embodiment, by obtaining cache data and a configuration file, wherein the configuration file includes first information and second information, the first information is used to indicate whether to enable the cache double-write function, and the second information is used to indicate that the first cache middleware is configured as the main cache, and when the first information indicates that the cache double-write function is enabled, cache data is written to the first cache middleware and the second cache middleware, wherein the first cache middleware and the second cache middleware are different. When switching is required, there is no need to migrate the cache data in different cache middlewares, and only the configuration file needs to be modified, thereby improving the flexibility of cache data processing and facilitating cache switching. By using the facade pattern to combine the first cache client object and the second cache client object into a double-write implementation class object, wherein the first cache client corresponds to the first cache middleware, and the second cache client corresponds to the second cache middleware, and when the first information indicates that the cache double-write function is enabled, cache data is written to the first cache middleware and the second cache middleware through the double-write implementation class, thereby effectively implementing the cache double-write function. After obtaining the cache data and the configuration file, when the first information indicates that the cache double-write function is not enabled, cache data is written to the first cache middleware, and cache data is not written to the second cache middleware. This further improves the flexibility of cache data processing and can support application in personalized application scenarios.

[0084] In some embodiments of the present disclosure, configuration update information may be obtained; and second information in the configuration file may be updated according to the configuration update information, wherein the updated second information is used to indicate that the second cache middleware is configured as the primary cache, thereby achieving flexible switching of the primary cache.

[0085] In some embodiments of the present disclosure, cache data may be read from the second cache middleware.

[0086] That is to say, if there is a need for cache switching, the second information in the configuration file can be updated based on the configuration update information, so that the updated second information is used to indicate that the second cache middleware is configured as the main cache. Subsequently, the cache data can be read directly from the switched second cache middleware, which can realize convenient switching of the main cache and improve cache switching efficiency.

[0087] In some embodiments of the present disclosure, when the first information indicates that the cache double-write function is enabled, the first information in the configuration file can be updated, wherein the updated first information is used to disable the cache double-write function, write cache data to the second cache middleware, and do not write cache data to the first cache middleware. This enables on-demand writing of cache data and improves application flexibility.

[0088] The examples for the above embodiment are as follows:

[0089] Take the example that the first cache middleware is Coherence and the second cache middleware is Redis.

[0090] The cache double-write function proposed in the embodiment of the present disclosure uses the facade pattern to combine the coherence client object (an optional example of the first cache client object) and the redis client object (an optional example of the second cache client object) into a double-write class object (an optional example of the double-write implementation class object), which will call the coherence and redis methods in sequence to synchronize the cache data into the two cache middlewares. When reading cache data, you can only read from the main cache, where the main cache can be configured through the configuration file. For example, if you want to switch coherence to redis, you only need to configure the main cache in the configuration file to redis to switch the cache from coherence to redis.

[0091] The cache dual write function proposed in the embodiment of the present disclosure refers to the simultaneous implementation of coherence and redis data writing when writing to the cache. The prerequisite for its implementation is that the cache read and write interface is defined in the application system code, and then the coherence client operation and the redis client operation are encapsulated into the implementation class of the interface. Since the two clients have a common interface, the two clients can be included in the dual write class through a new dual write implementation class, thereby realizing cache synchronous dual write.

[0092] There are three configuration items for cache dual write, namely, whether to enable the cache dual write function (cacheDual.switch=true / false), and which middleware is the primary cache (cacheDual.master=coherence / redis). To read the cache, you only need to read from the primary cache, not from both caches. When dual writing the cache, write to the primary cache first, then to the secondary cache, and return the result of the primary cache to the caller. The logical flow chart for determining which middleware is the primary cache is as follows: Figure 4 As shown, Figure 4 FIG. 1 is a schematic diagram of a logic flow for determining the primary cache in an embodiment of the present disclosure. Figure 5 As shown, Figure 5 It is a logic flow chart of the read cache and write cache in the embodiment of the present disclosure.

[0093] like Fig. 6A As shown, Fig. 6A It is a schematic diagram of the first stage implementation steps of switching from coherence to redis in the embodiment of the present disclosure. Among them, cacheDual.switch is an optional example of the first information, and cacheDual.master is an optional example of the second information. The steps of the first stage of switching from coherence to redis are: (1) Configure the following content in the configuration file: cacheDual.switch = true (the first information indicates an optional example of turning on the cache dual write function). cacheDual.master = coherence. (2) The application reads content from the database and uses the ParamDualRWService class to write to the cache. At this time, the cached data in the two middlewares are consistent. (3) When the application reads the cache, it reads from the coherence middleware.

[0094] like Figure 6B As shown, Figure 6B The figure is a schematic diagram of the second-stage implementation steps of switching from coherence to redis in the embodiment of the present disclosure. The second-stage steps of switching from coherence to redis are: (1) Configure the following content in the configuration file: cacheDual.switch = true; cacheDual.master = redis. (2) The application reads the content from the database and uses the ParamDualRWService class to write to the cache. At this time, the cache data in the two middlewares are consistent. (3) When the application reads the cache, it reads from the redis middleware and verifies whether the business is normal.

[0095] like Figure 6C As shown, Figure 6CIt is a schematic diagram of the implementation steps of the third stage of switching from coherence to redis in the embodiment of the present disclosure. The steps of the third stage of switching from coherence to redis are: (1) Configure the following content in the configuration file: cacheDual.switch = false (the first information indicates an optional example of not enabling the cache dual write function); cacheDual.master = redis. (2) The application reads content from the database and uses the ParamDualRWService class to write to the cache. At this time, only the redis middleware is written. (3) When the application reads the cache, it reads from the redis middleware and verifies whether the business is normal. At this point, the switch from coherence to redis is completed. Coherence can be offline.

[0096] This achieves data synchronization between coherence and redis, avoids data migration from coherence to redis, saves a lot of time, and improves customer experience. It is convenient to switch back from redis to coherence. You only need to modify the configuration file to achieve a smooth switch from redis to coherence.

[0097] Figure 7 A schematic diagram of the structure of a cache data processing device provided in an embodiment of the present disclosure.

[0098] like Figure 7 As shown, the cache data processing device 70 includes:

[0099] The first acquisition module 701 is used to acquire cache data.

[0100] The second acquisition module 702 is used to acquire a configuration file, wherein the configuration file includes first information and second information, the first information is used to indicate whether to enable the cache dual-write function, and the second information is used to indicate to configure the first cache middleware as the main cache.

[0101] Processing module 703 is used to write cache data to the first cache middleware and the second cache middleware when the first information indicates that the cache double-write function is enabled, wherein the first cache middleware and the second cache middleware are different. When the first information indicates that the cache double-write function is not enabled, the cache data is written to the first cache middleware, and the cache data is not written to the second cache middleware.

[0102] It should be noted that the above explanation of the cache data processing method is also applicable to the cache data processing device of this embodiment, and will not be repeated here.

[0103] In this embodiment, by obtaining cache data and a configuration file, wherein the configuration file includes first information and second information, the first information is used to indicate whether to enable the cache double-write function, and the second information is used to indicate that the first cache middleware is configured as the main cache, and when the first information indicates that the cache double-write function is enabled, cache data is written to the first cache middleware and the second cache middleware, wherein the first cache middleware and the second cache middleware are different. When switching is required, there is no need to migrate cache data in different cache middlewares, and only the configuration file needs to be modified, thereby improving the flexibility of cache data processing and facilitating cache switching.

[0104] As an example, Figure 8 is a schematic diagram of the structure of an electronic device shown in an exemplary embodiment of the present disclosure, such as Figure 8 As shown, the electronic device 700 may further include:

[0105] The memory 710 and the processor 720, a bus 730 connecting different components (including the memory 710 and the processor 720), the memory 710 stores a computer program, and when the processor 720 executes the program, the cache data processing method of the embodiment of the present disclosure is implemented.

[0106] Bus 730 represents one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, a processor or a local bus using any of a variety of bus architectures. For example, these architectures include but are not limited to Industry Standard Architecture (ISA) bus, Micro Channel Architecture (MAC) bus, Enhanced ISA bus, Video Electronics Standards Association (VESA) local bus and Peripheral Component Interconnect (PCI) bus.

[0107] The electronic device 700 typically includes a variety of electronic device readable media. These media can be any available media that can be accessed by the electronic device 700, including volatile and non-volatile media, removable and non-removable media.

[0108] The memory 710 may also include computer system readable media in the form of volatile memory, such as random access memory (RAM) 740 and / or cache memory 750. The electronic device 700 may further include other removable / non-removable, volatile / non-volatile computer system storage media. By way of example only, the storage system 760 may be used to read and write non-removable, non-volatile magnetic media ( Figure 8 not shown, usually called a "hard drive"). Although Figure 8Not shown, a disk drive for reading and writing to a removable non-volatile disk (e.g., a "floppy disk"), and an optical disk drive for reading and writing to a removable non-volatile optical disk (e.g., a CD-ROM, a DVD-ROM, or other optical media) may be provided. In these cases, each drive may be connected to the bus 730 via one or more data medium interfaces. The memory 710 may include at least one program product having a set (e.g., at least one) of program modules that are configured to perform the functions of the various embodiments of the present disclosure.

[0109] A program / utility 780 having a set (at least one) of program modules 770 may be stored, for example, in the memory 710, such program modules 770 including but not limited to an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment. The program modules 770 generally perform the functions and / or methods of the embodiments described in the present disclosure.

[0110] The electronic device 700 may also communicate with one or more external devices 790 (e.g., keyboard, pointing device, display 791, etc.), may also communicate with one or more devices that enable a user to interact with the electronic device 700, and / or communicate with any device that enables the electronic device 700 to communicate with one or more other computing devices (e.g., network card, modem, etc.). Such communication may be performed through an input / output (I / O) interface 792. Furthermore, the electronic device 700 may also communicate with one or more networks (e.g., local area network (LAN), wide area network (WAN) and / or public network, such as the Internet) through a network adapter 793. As shown, the network adapter 793 communicates with other modules of the electronic device 700 through a bus 730. It should be understood that, although not shown in the figure, other hardware and / or software modules may be used in conjunction with the electronic device 700, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.

[0111] The processor 720 executes various functional applications and data processing by running the programs stored in the memory 710 .

[0112] It should be noted that the implementation process and technical principles of the electronic device of this embodiment refer to the aforementioned explanation of the cache data processing method of the embodiment of the present disclosure, and will not be repeated here.

[0113] In order to implement the above embodiments, the present disclosure also proposes an electronic device, including: a processor, and a memory communicatively connected to the processor; the memory stores computer-executable instructions; the processor executes the computer-executable instructions stored in the memory to implement the method provided by the above embodiments.

[0114] In order to implement the above embodiments, the present disclosure further proposes a computer-readable storage medium, in which computer-executable instructions are stored. When the computer-executable instructions are executed by a processor, they are used to implement the methods provided by the above embodiments.

[0115] In order to implement the above embodiments, the present disclosure also proposes a computer program product, including a computer program, which implements the methods provided by the above embodiments when executed by a processor.

[0116] The collection, storage, use, processing, transmission, provision and disclosure of user personal information involved in this disclosure shall comply with the relevant laws and regulations and shall not violate public order and good morals.

[0117] It should be noted that personal information from users should be collected for legitimate and reasonable purposes and should not be shared or sold outside of these legitimate uses. In addition, such collection / sharing should be carried out after receiving the user's informed consent, including but not limited to notifying the user to read the user agreement / user notice and sign the agreement / authorization including authorization of relevant user information before the user uses the function. In addition, any necessary steps should be taken to protect and safeguard access to such personal information data and ensure that others who have access to personal information data comply with its privacy policy and procedures.

[0118] The present disclosure anticipates providing implementation schemes for users to selectively block the use or access of personal information data. That is, the present disclosure anticipates providing hardware and / or software to prevent or block access to such personal information data. Once the personal information data is no longer needed, risks can be minimized by limiting data collection and deleting the data. In addition, when applicable, such personal information is de-identified to protect the privacy of the user.

[0119] In the description of the aforementioned embodiments, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present disclosure. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner. In addition, those skilled in the art may combine and combine the different embodiments or examples described in this specification and the features of the different embodiments or examples, unless they are contradictory.

[0120] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one of the features. In the description of the present disclosure, "plurality" means at least two, such as two, three, etc., unless otherwise clearly and specifically defined.

[0121] Any process or method description in a flowchart or otherwise described herein may be understood to represent a module, segment or portion of code that includes one or more executable instructions for implementing the steps of a custom logical function or process, and the scope of the preferred embodiments of the present disclosure includes additional implementations in which functions may not be performed in the order shown or discussed, including performing functions in a substantially simultaneous manner or in reverse order depending on the functions involved, which should be understood by technicians in the technical field to which the embodiments of the present disclosure belong.

[0122] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as an ordered list of executable instructions for implementing logical functions, and can be embodied in any computer-readable medium for use by an instruction execution system, device or apparatus (such as a computer-based system, a system including a processor, or other system that can fetch instructions from an instruction execution system, device or apparatus and execute the instructions), or in combination with these instruction execution systems, devices or apparatuses. For the purpose of this specification, "computer-readable medium" can be any device that can contain, store, communicate, propagate or transmit a program for use by an instruction execution system, device or apparatus, or in combination with these instruction execution systems, devices or apparatuses. More specific examples of computer-readable media (a non-exhaustive list) include the following: an electrical connection with one or more wires (electronic device), a portable computer disk box (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable and programmable read-only memory (EPROM or flash memory), a fiber optic device, and a portable compact disk read-only memory (CDROM). In addition, the computer-readable medium may even be paper or other suitable medium on which the program is printed, since the program may be obtained electronically, for example, by optically scanning the paper or other medium and then editing, interpreting or processing in other suitable ways if necessary, and then stored in a computer memory.

[0123] It should be understood that the various parts of the present disclosure can be implemented in hardware, software, firmware or a combination thereof. In the above-mentioned embodiments, multiple steps or methods can be implemented in software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented in hardware, as in another embodiment, any one of the following technologies known in the art or a combination thereof can be used to implement: a discrete logic circuit having a logic gate circuit for implementing a logic function for a data signal, a dedicated integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.

[0124] A person skilled in the art may understand that all or part of the steps in the method for implementing the above-mentioned embodiment may be completed by instructing related hardware through a program, and the program may be stored in a computer-readable storage medium, which, when executed, includes one or a combination of the steps of the method embodiment.

[0125] In addition, each functional unit in each embodiment of the present disclosure may be integrated into a processing module, or each unit may exist physically separately, or two or more units may be integrated into one module. The above-mentioned integrated module may be implemented in the form of hardware or in the form of a software functional module. If the integrated module is implemented in the form of a software functional module and sold or used as an independent product, it may also be stored in a computer-readable storage medium.

[0126] The storage medium mentioned above may be a read-only memory, a disk or an optical disk, etc. Although the embodiments of the present disclosure have been shown and described above, it can be understood that the above embodiments are exemplary and cannot be understood as limitations of the present disclosure. A person of ordinary skill in the art may change, modify, replace and modify the above embodiments within the scope of the present disclosure.

Claims

1. A cache data processing method, characterized in that: The method comprises: Get cache data; Obtain a configuration file, wherein the configuration file includes first information and second information, the first information is used to indicate whether to enable the cache double-write function, and the second information is used to indicate that the first cache middleware is configured as a primary cache; When the first information indicates that a cache double-write function is enabled, writing the cache data to the first cache middleware and the second cache middleware, wherein the first cache middleware and the second cache middleware are different; When the first information indicates that the cache double-write function is not enabled, the cache data is written to the first cache middleware, and the cache data is not written to the second cache middleware.

2. The method according to claim 1, characterized in that: After writing the cache data to the first cache middleware and the second cache middleware, the method further includes: Detect whether writing the cache data to the first cache middleware is successful, and obtain a detection result; When the detection result indicates that the writing is successful, returning the writing result of the first cache middleware; When the detection result indicates that the writing is not successful, the writing result of the second cache middleware is returned.

3. The method according to claim 1, characterized in that The step of writing the cache data to the first cache middleware and the second cache middleware comprises: Firstly write the cache data to the first cache middleware, and then write the cache data to the second cache middleware; The first cache middleware and the second cache middleware are ensured to meet data consistency conditions.

4. The method according to claim 1, characterized in that: The step of writing the cache data to the first cache middleware and the second cache middleware comprises: Combine the first cache client object and the second cache client object into a double-write implementation class object using a facade pattern, wherein the first cache client corresponds to the first cache middleware, and the second cache client corresponds to the second cache middleware; The cache data is written to the first cache middleware and the second cache middleware through the dual-write implementation class.

5. The method according to claim 1, characterized in that The method further comprises: The cache data is read from the first cache middleware.

6. The method according to claim 1, characterized in that The method further comprises: Get configuration update information; The second information in the configuration file is updated according to the configuration update information, wherein the updated second information is used to indicate that the second cache middleware is configured as a primary cache.

7. The method according to claim 6, characterized in that The method further comprises: When the first information indicates that the cache double-write function is enabled, updating the first information in the configuration file, wherein the updated first information is used to disable the cache double-write function; The cache data is written to the second cache middleware, and the cache data is not written to the first cache middleware.

8. The method according to claim 7, characterized in that The method further comprises: The cache data is read from the second cache middleware.

9. A cache data processing device, characterized in that: The device comprises: A first acquisition module, used to acquire cache data; A second acquisition module is used to acquire a configuration file, wherein the configuration file includes first information and second information, the first information is used to indicate whether to enable the cache dual-write function, and the second information is used to indicate that the first cache middleware is configured as a primary cache; A processing module, used for writing the cache data to the first cache middleware and the second cache middleware when the first information indicates that the cache double-write function is enabled, wherein the first cache middleware and the second cache middleware are different; and for writing the cache data to the first cache middleware and not writing the cache data to the second cache middleware when the first information indicates that the cache double-write function is not enabled.

10. An electronic device, characterized in that: include: A processor, and a memory communicatively connected to the processor; The memory stores computer-executable instructions; The processor executes the computer-executable instructions stored in the memory to implement the method according to any one of claims 1 to 8.

11. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, which are used to implement the method according to any one of claims 1 to 8 when executed by a processor.

12. A computer program product, characterized in that The invention comprises a computer program, which implements the method according to any one of claims 1 to 8 when being executed by a processor.

Citation Information

Patent Citations

  • Cache realization method and device

    CN106940660A

  • Data consistency processing method, device, equipment and distributed file system

    CN113377735A

  • Data storage method and device, computer equipment and storage medium

    CN116107504A

  • Cache data writing method and device and cache data reading method and device

    CN118151836A