Data reading method and device

Through the cached data timeout failure detection and management at the interface level, the problem of historical data following the old threshold after the failure time threshold is updated in the cache system is solved, real-time and accuracy of cached data are achieved, and data errors are avoided.

CN120429322APending Publication Date: 2025-08-05BEIJING JINGDONG TUOXIAN TECH CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202410157508.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-02-04
Publication Date
2025-08-05

AI Technical Summary

Technical Problem

In the prior art, after the cache system has been updated for the failure time threshold, the historical data still complies with the old threshold, resulting in the data returned by the interface being unable to meet the real-time requirements and data errors may occur.

Method used

Through the cached data timeout failure detection and management at the interface level, it is detected whether the storage time of the data to be queried exceeds the failure time threshold. If it exceeds, the cached data will be updated from the database to ensure that the failure time threshold takes effect immediately.

Benefits of technology

Real-time requirements for cached data are realized, data errors are avoided, and system management and control capabilities and data accuracy are improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120429322A_ABST
    Figure CN120429322A_ABST
Patent Text Reader

Abstract

The invention discloses a data reading method and device, and relates to the technical field of computers. A specific embodiment of the method comprises the following steps: receiving a query request based on calling a target interface; in response to the situation that to-be-queried data corresponding to the target interface exists in a preset interface cache, detecting whether the storage duration of the to-be-queried data in the interface cache is greater than a failure duration threshold value of the target interface or not; and in response to the condition that the storage duration is greater than the failure duration threshold, reading the to-be-queried data from a preset database corresponding to the target interface, updating the read to-be-queried data to the interface cache, and returning the read to-be-queried data. According to the embodiment, the overtime failure detection and management of the cache data of the specific interface can be realized on the interface level, and the immediate effectiveness of the updated failure duration threshold on the cache data is realized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a data reading method and device. Background Art

[0002] In a computer system, it is necessary to define an interface to query data from other systems or databases. In scenarios such as high concurrency, interface caching technology is generally used for acceleration. Reading data from the interface cache takes more than 10 times less time than directly reading from the database. Interface caching technology means that when querying data for the first time, the source data storage is directly requested, and the system stores the data result in the cache system corresponding to the interface. When querying the same data again, the system determines whether the data has been stored in the cache. If so, it skips the source data storage and directly obtains the data from the cache, thereby improving the data access speed. A data expiration duration threshold can be set in the cache system. When the storage duration of data in the cache is greater than the threshold, it means the data has expired, and at this time, the cache system will delete the data.

[0003] Currently, the built-in functions of the cache system are generally used to configure the opening, closing, and data expiration duration threshold of the cache. When the expiration duration threshold is updated, the updated threshold can only be applied to the new data written to the cache thereafter. The existing historical data in the cache follows the threshold before the update, which cannot meet the real-time requirements of specific systems for cache data. For example, for an interface that requires the expiration duration threshold of cache data to be updated from 1 hour to 1 minute due to data real-time requirements and requires immediate effectiveness, but according to the existing technology, after the cache system updates the threshold, a large amount of historical data still maintains a storage duration of 1 hour, resulting in the data returned by the interface not meeting the real-time requirements and may also cause data errors. Summary of the Invention

[0004] In view of this, embodiments of the present invention provide a data reading method and device, which can implement the detection and management of the timeout expiration of cache data for a specific interface at the interface level, and achieve the immediate effectiveness of the updated expiration duration threshold for cache data.

[0005] To achieve the above object, according to one aspect of the present invention, a data reading method is provided.

[0006] The data reading method of the embodiments of the present invention includes: receiving a query request based on calling a target interface; in response to the presence of the data to be queried corresponding to the target interface in a preset interface cache, detecting whether the storage duration of the data to be queried in the interface cache is greater than the expiration duration threshold of the target interface; in response to the storage duration being greater than the expiration duration threshold, reading the data to be queried from a preset database corresponding to the target interface, updating the read data to be queried to the interface cache and returning it.

[0007] Optionally, the method further includes: after receiving the query request based on the invocation of the target interface, determining whether the target interface enables caching according to the cache configuration information of the target interface; if caching is enabled, performing the step of determining whether the data to be queried exists in the interface cache; before detecting whether the storage duration of the data to be queried in the interface cache is greater than the expiration duration threshold preset for the target interface, obtaining the expiration duration threshold of the target interface from the cache configuration information of the target interface.

[0008] Optionally, the method further includes: in the case where it is determined according to the cache configuration information of the target interface that the target interface does not enable caching, reading the data to be queried from the database and returning it; in the case where it is determined that the target interface enables caching and the data to be queried does not exist in the interface cache, reading the data to be queried from the database and returning it; in the case where it is determined that the target interface enables caching, the data to be queried exists in the interface cache, and the storage duration of the data to be queried in the interface cache is less than or equal to the expiration duration threshold preset for the target interface, reading the data to be queried from the interface cache and returning it.

[0009] Optionally, the method is executed by a specific service encapsulated based on the target interface, and the specific service provides methods for setting the cache enable status and the expiration duration threshold in the cache configuration information; and, the interface cache corresponds to multiple interfaces and stores the interface data of each interface in isolation.

[0010] Optionally, determining that the data to be queried corresponding to the target interface exists in the preset interface cache includes: determining that the data to be queried exists in the interface data of the target interface stored in the interface cache.

[0011] Optionally, the method further includes: at the same time as or after writing the data into the interface cache, recording the start storage time of the data; after determining that the data to be queried corresponding to the target interface exists in the preset interface cache, subtracting the start storage time of the data to be queried from the current time to obtain the storage duration of the data to be queried.

[0012] To achieve the above object, according to another aspect of the present invention, a data reading device is provided.

[0013] The data reading device according to an embodiment of the present invention includes: a request receiving unit, configured to receive a query request based on invoking a target interface; a detection unit, configured to: in response to the existence of the data to be queried corresponding to the target interface in a preset interface cache, detect whether the storage duration of the data to be queried in the interface cache is greater than the invalid duration threshold of the target interface; a reading unit, configured to: in response to the storage duration being greater than the invalid duration threshold, read the data to be queried from a preset database corresponding to the target interface, update the read data to be queried to the interface cache and return it.

[0014] Optionally, the detection unit is further configured to: after receiving the query request based on invoking the target interface, determine whether the target interface enables caching according to the cache configuration information of the target interface; if it enables caching, execute the step of determining whether the data to be queried exists in the interface cache; before detecting whether the storage duration of the data to be queried in the interface cache is greater than the invalid duration threshold preset for the target interface, obtain the invalid duration threshold of the target interface from the cache configuration information of the target interface.

[0015] To achieve the above object, according to another aspect of the present invention, there is provided an electronic device.

[0016] An electronic device of the present invention includes: one or more processors; a storage device, configured to store one or more programs, and when the one or more programs are executed by the one or more processors, the one or more processors implement the data reading method provided by the present invention.

[0017] To achieve the above object, according to still another aspect of the present invention, there is provided a computer-readable storage medium.

[0018] A computer-readable storage medium of the present invention stores a computer program thereon, and when the program is executed by a processor, it implements the data reading method provided by the present invention.

[0019] According to the technical solution of the present invention, the above embodiments in the present invention have the following advantages or beneficial effects:

[0020] After receiving a query request based on a call to a target interface, if a specific service encapsulated based on the target interface determines that there is data to be queried corresponding to the target interface in the preset interface cache, it detects whether the storage duration of the data to be queried in the interface cache is greater than the latest expiration duration threshold preset for the target interface. If the above storage duration is greater than the expiration duration threshold, the specific service reads the data to be queried from the preset database corresponding to the target interface, updates the read data to be queried to the interface cache and returns it; if the above storage duration is less than or equal to the expiration duration threshold, the specific service reads the data to be queried from the interface cache and returns it. In the above manner, on the premise of meeting the basic functions such as reading and writing data of the call interface through a specific service, the interface cache opening and closing functions and the expiration duration threshold configuration function of each interface are implemented based on the specific service, and the timeout expiration detection and processing of any cached data are implemented based on the specific service and its data expiration detection and reading steps, so that any cached data of the corresponding interface complies with the current expiration duration threshold, achieving the immediate effect of the current configuration of the expiration duration threshold of each interface, solving the problem that the real-time performance of cached data does not meet the requirements, and avoiding data errors.

[0021] The further effects of the above non-conventional optional methods will be described below in conjunction with specific embodiments. BRIEF DESCRIPTION OF THE DRAWINGS

[0022] The drawings are used to better understand the present invention and do not constitute an improper limitation to the present invention. Among them:

[0023] Figure 1 is a schematic diagram of the main steps of the data reading method in an embodiment of the present invention;

[0024] Figure 2 is a schematic diagram of the system architecture of the data reading method in an embodiment of the present invention;

[0025] Figure 3 is a schematic diagram of the functional modules of the data reading method in an embodiment of the present invention;

[0026] Figure 4 is a schematic diagram of the specific execution steps of the data reading method in an embodiment of the present invention;

[0027] Figure 5 is a schematic diagram of the components of the data reading device in an embodiment of the present invention;

[0028] Figure 6 is an exemplary system architecture diagram to which an embodiment of the present invention can be applied;

[0029] Figure 7 is a schematic diagram of the structure of an electronic device for implementing the data reading method in an embodiment of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0030] The exemplary embodiments of the present invention will be described below in conjunction with the accompanying drawings. Various details of the embodiments of the present invention are included to facilitate understanding, and they should be considered merely exemplary. Therefore, those of ordinary skill in the art should recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of the present invention. Similarly, for the sake of clarity and conciseness, descriptions of well-known functions and structures are omitted in the following description.

[0031] It should be noted that, without conflict, the embodiments of the present invention and the technical features in the embodiments can be combined with each other.

[0032] Figure 1 It is a schematic diagram of the main steps of the data reading method according to the embodiments of the present invention.

[0033] As shown in Figure 1 the data reading method of the embodiments of the present invention can be executed by a specific service encapsulated based on a target interface. The data reading method can be specifically executed according to the following steps:

[0034] Step S101: Receive a query request based on calling the target interface.

[0035] In this step, the client initiates a query request by calling the target interface. As a preferred solution, after receiving the query request, the specific service determines whether the target interface enables caching according to the cache configuration information of the target interface; if it is enabled, the specific service executes the subsequent steps to determine whether the data to be queried exists in the interface cache; if it is not enabled (i.e., the cache is closed), the specific service reads the data to be queried from the database and returns it.

[0036] In the embodiments of the present invention, the interface cache can be implemented based on a known cache system, which can correspond to multiple interfaces and isolate and store the interface data of each interface. In practical applications, when the specific service writes data into the interface cache or after that, it can record the start storage time of the data.

[0037] The above database can be a database such as Mysql or any data storage system. Preferably, the above specific service can provide methods for setting the cache enable status (including cache enable and cache close) and the expiration duration threshold of the cached data in the cache configuration information. Specifically, the specific service can provide methods to configure whether any interface enables caching (i.e., uses the interface cache) and the expiration duration threshold of any interface. When the storage duration of the interface data stored in the interface cache of any interface is greater than the expiration duration threshold, it means that the data has expired (i.e., is overdue).

[0038] Step S102: In response to the existence of to-be-queried data corresponding to the target interface in the preset interface cache, it is detected whether the storage time of the to-be-queried data in the interface cache is greater than the expiration time threshold of the target interface.

[0039] In the case where the target interface has cache enabled, in this step, the specific service determines whether the data to be queried corresponding to the target interface exists in the preset interface cache. In a specific application, the specific method of the above judgment is that the specific service determines whether the data to be queried exists in the interface data of the target interface stored in the interface cache. If not, the specific service reads the data to be queried from the database and returns it; if it exists, the specific service obtains the current expiration time threshold of the target interface from the cache configuration information of the target interface, and detects whether the storage time of the data to be queried in the interface cache is greater than the expiration time threshold preset for the target interface; if it is greater, execute step S103; if it is detected that the storage time of the data to be queried in the interface cache is less than or equal to the expiration time threshold preset for the target interface, the specific service reads the data to be queried from the interface cache and returns it. It can be understood that in the above process, after determining that the data to be queried exists in the interface cache, the specific service can subtract the start storage time of the data to be queried from the current time to obtain the storage time of the data to be queried and then perform the above detection.

[0040] Step S103: In response to the storage duration being greater than the expiration duration threshold, the data to be queried is read from the preset database corresponding to the target interface, and the read data to be queried is updated to the interface cache and returned.

[0041] In this step, when the specific service determines that the storage time is greater than the expiration time threshold, it determines that the data to be queried in the interface cache is invalid. At this time, the specific service reads the data to be queried as the source data from the database, updates the read data to be queried to the interface cache and returns it.

[0042] The technical solution of the embodiments of the present invention addresses existing issues such as the inability to dynamically enable and disable interface caches and adjust expiration time thresholds during system operation. This provides the system with more flexible cache control capabilities, enabling changes to cache attributes without modifying source code or redeploying the system. This significantly improves system management and control capabilities and reduces resource loss associated with repeated system deployments. The embodiments of the present invention can implement real-time storage expiration for cached data, avoiding the problem of historical cached data failing to meet real-time requirements.

[0043] A specific embodiment of the present invention is described below. Figures 2 to 4 .

[0044] like Figure 2As shown, the interface cache framework (hereinafter referred to as the framework) provides a cache control wrapper service (i.e., a specific service) to encapsulate the cache ability of the interface. It internally encapsulates a cache proxy service to perform data read and write functions based on interface calls. When the client first accesses a certain data, the cache control wrapper service reads the data from the data storage (i.e., the aforementioned database) and stores it in the interface cache. When the client accesses it again, it directly reads from the interface cache. On the other hand, the framework provides a cache management module to implement the cache management function of the cache control wrapper service. The cache control wrapper service can enable and disable the interface cache for any interface and adjust the expiration duration threshold based on the configuration of the operation personnel and the cache management module.

[0045] The framework provides wrapper objects for each cached data, which not only record the original cached data but also record the start storage time of the data for subsequent verification of whether the cached data has expired. When the business system queries data through the framework by calling an interface, it first queries the interface cache. If the cache is not hit, it will query the database to obtain the data and write the data and the current time (the start storage time of the data) into the cache. If the cache is hit, it calculates the storage duration of the data and determines whether the data has expired based on the latest expiration duration threshold; if it has expired, it reads the data from the database, returns it, and writes it into the cache. If it has not expired, it directly reads the data from the cache.

[0046] See Figure 3 . In this embodiment, the cache proxy module (CacheProxy) is abstracted to provide the following specific methods, including data query, data deletion, data setting, etc. The cache management module (InterfaceCacheManager) is abstracted to provide centralized management of the cache control wrapper services for each interface, and provides methods such as closing the interface cache, opening the interface cache, and changing the expiration duration threshold. The cache control wrapper module (i.e., the cache control wrapper service, InterfaceCacheWrapper) is abstracted to provide packaging for the interfaces in the business system, enabling the business interfaces to have the cache ability, and providing methods such as closing the interface cache, opening the interface cache, changing the expiration duration threshold, data query, data deletion, data setting, etc., and can perform operations on the source data or configure the cache according to the current settings of the interface. The cache object (CacheObj) is abstracted, and its internal data field is used to retain the original data of the interface cache, and the cacheTime field is used to save the start storage time of the data. In Figure 3 , use means reference, void means null, string means string, long means long integer, and object means object type.

[0047] Figure 4It is a schematic diagram of the specific execution steps of the data reading method in the embodiment of the present invention. The specific execution details have been described above and will not be repeated here.

[0048] In the embodiment of the present invention, a dynamically controllable interface cache model is abstracted, and a complete class structure is designed. Specifically, a cache management module (InterfaceCacheManager), a cache control wrapper module (InterfaceCacheWapper), a cache proxy module (CacheProxy), a cache object (CacheObj), etc. of the interface cache model are abstracted. The above solutions can dynamically open and close the interface cache during the system operation, adjust the cache time, enabling the system to have more flexible cache control capabilities. Without modifying the source code and redeploying the system, the cache attributes can be changed. It not only supports the real-time effective ability of increasing the cache time (i.e., increasing the invalidation duration threshold), but also supports the real-time effective ability of reducing the cache time (i.e., reducing the invalidation duration threshold), greatly improving the system's management and control capabilities and data accuracy.

[0049] It should be noted that in the technical solution of the present invention, aspects such as the collection, gathering, update, analysis, processing, use, transmission, and storage of user personal information may involve are all in compliance with the provisions of relevant laws and regulations, are used for legal purposes, and do not violate public order and good customs. Necessary measures are taken for user personal information to prevent illegal access to user personal information data, and to safeguard the security of user personal information, network security, and national security.

[0050] For the foregoing method embodiments, for the sake of convenience of description, they are expressed as a series of action combinations. However, those skilled in the art should know that the present invention is not limited by the described action sequence. In fact, some steps can be carried out in other sequences or simultaneously. In addition, those skilled in the art should also know that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily essential for implementing the present invention.

[0051] To better implement the above solutions of the embodiments of the present invention, relevant devices for implementing the above solutions are also provided below.

[0052] Please refer to Figure 5 As shown, the data reading device 500 provided by the embodiment of the present invention may include: a request receiving unit 501, a detection unit 502, and a reading unit 503.

[0053] Among them, the request receiving unit 501 is used to receive a query request based on invoking a target interface; the detection unit 502 is used to: in response to the existence of the data to be queried corresponding to the target interface in the preset interface cache, detect whether the storage duration of the data to be queried in the interface cache is greater than the failure duration threshold of the target interface; the reading unit 503 is used to: in response to the storage duration being greater than the failure duration threshold, read the data to be queried from the preset database corresponding to the target interface, update the read data to be queried to the interface cache and return it.

[0054] In an embodiment of the present invention, the detection unit 502 may further be used to: after receiving the query request based on invoking the target interface, determine whether the target interface enables caching according to the cache configuration information of the target interface; if it is enabled, execute the step of determining whether the data to be queried exists in the interface cache; before detecting whether the storage duration of the data to be queried in the interface cache is greater than the failure duration threshold preset for the target interface, obtain the failure duration threshold of the target interface from the cache configuration information of the target interface.

[0055] In specific applications, the reading unit 503 may further be used to: in the case where it is determined according to the cache configuration information of the target interface that the target interface does not enable caching, read the data to be queried from the database and return it; in the case where it is determined that the target interface enables caching and the data to be queried does not exist in the interface cache, read the data to be queried from the database and return it; in the case where it is determined that the target interface enables caching, the data to be queried exists in the interface cache, and the storage duration of the data to be queried in the interface cache is less than or equal to the failure duration threshold preset for the target interface, read the data to be queried from the interface cache and return it.

[0056] In practical applications, the method is executed by a specific service encapsulated based on the target interface, and the specific service provides a method for setting the cache enable status and the failure duration threshold in the cache configuration information; and, the interface cache corresponds to multiple interfaces and stores the interface data of each interface in isolation.

[0057] Preferably, the detection unit 502 may further be used to: determine that the data to be queried exists in the interface data of the target interface stored in the interface cache.

[0058] In addition, in the embodiment of the present invention, the detection unit 502 may be further configured to: record the start storage time of the data while or after writing the data into the interface cache; after determining that there is data to be queried corresponding to the target interface in the preset interface cache, subtract the start storage time of the data to be queried from the current time to obtain the storage duration of the data to be queried.

[0059] According to the technical solution of the embodiment of the present invention, after receiving a query request based on calling a target interface, if a specific service encapsulated by the target interface determines that there is data to be queried corresponding to the target interface in the preset interface cache, it detects whether the storage duration of the data to be queried in the interface cache is greater than the latest failure duration threshold preset for the target interface. If the above storage duration is greater than the failure duration threshold, the specific service reads the data to be queried from the preset database corresponding to the target interface, updates the read data to the interface cache and returns it; if the above storage duration is less than or equal to the failure duration threshold, the specific service reads the data to be queried from the interface cache and returns it. Through the above method, on the premise of meeting the basic functions such as reading and writing data of the calling interface through a specific service, the functions of opening and closing the interface cache and configuring the failure duration threshold of each interface are realized based on the specific service, and the timeout failure detection and processing of any cached data are realized based on the specific service and its data failure detection and reading steps, so that any cached data of the corresponding interface complies with the current failure duration threshold, realizing the immediate effect of the current configuration of the failure duration threshold of each interface, solving the problem that the real-time performance of cached data does not meet the requirements, and avoiding data errors.

[0060] Figure 6 An exemplary system architecture 600 to which the data reading method or data reading device of the embodiment of the present invention can be applied is shown.

[0061] As Figure 6 shown, the system architecture 600 may include terminal devices 601, 602, 603, a network 604, and a server 605 (this architecture is only an example, and the components included in the specific architecture can be adjusted according to the specific situation of the invention). The network 604 is used to provide a medium for communication links between the terminal devices 601, 602, 603 and the server 605. The network 604 may include various connection types, such as wired, wireless communication links, or fiber optic cables, etc.

[0062] Users can use the terminal devices 601, 602, 603 to interact with the server 605 through the network 604 to receive or send messages, etc. Various client applications, such as search applications (only for example), may be installed on the terminal devices 601, 602, 603.

[0063] The terminal devices 601, 602, and 603 can be various electronic devices with a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, desktop computers, and so on.

[0064] The server 605 can be a server that provides various services, such as a background server (only for example) that supports search applications operated by users using the terminal devices 601, 602, and 603. The background server can process the received query requests and feedback the processing results (such as query results - only for example) to the terminal devices 601, 602, and 603.

[0065] It should be noted that the data reading method provided by the embodiments of the present invention is generally executed by the server 605. Correspondingly, the data reading device is generally disposed in the server 605.

[0066] It should be understood that Figure 6 the numbers of the terminal devices, networks, and servers in

[0067] The present invention also provides an electronic device. The electronic device according to the embodiments of the present invention includes: one or more processors; a storage device for storing one or more programs, and when the one or more programs are executed by the one or more processors, the one or more processors implement the data reading method provided by the present invention.

[0068] Next, refer to Figure 7 , which shows a schematic structural diagram of a computer system 700 of an electronic device suitable for implementing the embodiments of the present invention. Figure 7 The shown electronic device is only an example and should not bring any limitation to the functions and usage scope of the embodiments of the present invention.

[0069] As Figure 7 shown, the computer system 700 includes a central processing unit (CPU) 701, which can perform various appropriate actions and processes according to the programs stored in the read-only memory (ROM) 702 or the programs loaded from the storage section 708 into the random access memory (RAM) 703. In the RAM 703, various programs and data required for the operation of the computer system 700 are also stored. The CPU 701, ROM 702, and RAM 703 are connected to each other through a bus 704. The input / output (I / O) interface 705 is also connected to the bus 704.

[0070] The following components are connected to the I / O interface 705: an input section 706 including a keyboard, a mouse, etc.; an output section 707 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc. as well as a speaker, etc.; a storage section 708 including a hard disk, etc.; and a communication section 709 including a network interface card such as a LAN card, a modem, etc. The communication section 709 performs communication processing via a network such as the Internet. A drive 710 is also connected to the I / O interface 705 as required. A removable medium 711 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc. is installed on the drive 710 as required so that a computer program read therefrom is installed into the storage section 708 as required.

[0071] Specifically, according to the embodiments disclosed in the present invention, the process described in the above main step diagram can be implemented as a computer software program. For example, an embodiment of the present invention includes a computer program product which includes a computer program carried on a computer-readable medium, and the computer program contains program codes for executing the method shown in the main step diagram. In the above embodiment, the computer program can be downloaded and installed from a network via the communication section 709, and / or installed from the removable medium 711. When the computer program is executed by the central processing unit 701, the above functions defined in the system of the present invention are executed.

[0072] It should be noted that the computer-readable medium shown in the present invention can be a computer-readable signal medium, a computer-readable storage medium, or any combination of the above two. A computer-readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the above. More specific examples of a computer-readable storage medium can include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present invention, a computer-readable storage medium can be any tangible medium that contains or stores a program, and this program can be used by or in combination with an instruction execution system, apparatus, or device. In the present invention, a computer-readable signal medium can include a data signal propagated in a baseband or as part of a carrier wave, which carries computer-readable program code. Such a propagated data signal can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. A computer-readable signal medium can also be any computer-readable medium other than a computer-readable storage medium, and this computer-readable medium can send, propagate, or transmit a program for use by or in combination with an instruction execution system, apparatus, or device. The program code contained on a computer-readable medium can be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.

[0073] The flowcharts and block diagrams in the accompanying drawings illustrate the possible architectures, functions, and operations of systems, methods, and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagram can represent a module, a program segment, or a part of code, and the above module, program segment, or part of code contains one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions marked in the blocks may occur in a different order than that marked in the accompanying drawings. For example, two consecutive blocks shown may actually be executed substantially in parallel, and they may sometimes be executed in the reverse order, depending on the functions involved. It should also be noted that each block in the block diagram or flowchart, and the combination of blocks in the block diagram or flowchart, can be implemented by a dedicated hardware-based system for performing the specified functions or operations, or can be implemented by a combination of dedicated hardware and computer instructions.

[0074] The units involved in the embodiments of the present invention can be implemented in software or in hardware. The described units can also be provided in a processor. For example, it can be described as: a processor includes a request receiving unit, a detection unit, and a reading unit. Among them, the names of these units do not constitute a limitation on the unit itself in some cases. For example, the request receiving unit can also be described as "a unit that provides query request parameters to the detection unit".

[0075] As another aspect, the present invention also provides a computer-readable medium. The computer-readable medium can be included in the device described in the above embodiments; or it can exist separately and not be assembled into the device. The above computer-readable medium carries one or more programs. When the above one or more programs are executed by the device, the steps executed by the device include: receiving a query request based on calling a target interface; in response to the existence of the data to be queried corresponding to the target interface in a preset interface cache, detecting whether the storage duration of the data to be queried in the interface cache is greater than the failure duration threshold of the target interface; in response to the storage duration being greater than the failure duration threshold, reading the data to be queried from a preset database corresponding to the target interface, updating the read data to be queried to the interface cache and returning it.

[0076] In the technical solution of the embodiments of the present invention, after receiving a query request based on calling a target interface, if a specific service encapsulated based on the target interface determines that there is data to be queried corresponding to the target interface in the preset interface cache, it detects whether the storage duration of the data to be queried in the interface cache is greater than the latest failure duration threshold preset for the target interface. If the above storage duration is greater than the failure duration threshold, the specific service reads the data to be queried from a preset database corresponding to the target interface, updates the read data to be queried to the interface cache and returns it; if the above storage duration is less than or equal to the failure duration threshold, the specific service reads the data to be queried from the interface cache and returns it. In the above manner, on the premise of meeting basic functions such as reading and writing data of the calling interface through a specific service, the opening and closing functions of the interface cache and the configuration function of the failure duration threshold for each interface are implemented based on the specific service, and the timeout failure detection and processing for any cached data are implemented based on the specific service and its data failure detection and reading steps, so that any cached data of the corresponding interface complies with the current failure duration threshold, realizing the immediate effectiveness of the current configuration of the failure duration threshold for each interface, solving the problem that the real-time performance of cached data does not meet the requirements, and avoiding data errors.

[0077] The above specific embodiments do not constitute a limitation on the protection scope of the present invention. Those skilled in the art should understand that various modifications, combinations, sub-combinations and substitutions can occur depending on design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principle of the present invention shall be included within the protection scope of the present invention.

Claims

1. A data reading method, characterized in that: include: Receive query requests based on calling the target interface; In response to the presence of to-be-queried data corresponding to the target interface in a preset interface cache, detecting whether a storage time of the to-be-queried data in the interface cache is greater than an expiration time threshold of the target interface; In response to the storage time being greater than the expiration time threshold, the data to be queried is read from a preset database corresponding to the target interface, and the read data to be queried is updated to the interface cache and returned.

2. The data reading method according to claim 1, wherein: The method further comprises: After receiving the query request based on calling the target interface, determining whether the target interface has cache enabled according to cache configuration information of the target interface; If enabled, executing the step of determining whether the data to be queried exists in the interface cache; Before detecting whether the storage time of the data to be queried in the interface cache is greater than the expiration time threshold preset for the target interface, the expiration time threshold of the target interface is obtained from the cache configuration information of the target interface.

3. The data reading method according to claim 2, wherein: The method further comprises: If it is determined according to the cache configuration information of the target interface that the cache of the target interface is not enabled, reading the data to be queried from the database and returning the data; If it is determined that the target interface has cache enabled and the data to be queried does not exist in the interface cache, reading the data to be queried from the database and returning the data; When it is determined that the target interface has cache enabled, the data to be queried exists in the interface cache, and the storage duration of the data to be queried in the interface cache is less than or equal to the expiration duration threshold preset for the target interface, the data to be queried is read from the interface cache and returned.

4. The data reading method according to claim 2 or 3, characterized in that: The method is executed by a specific service encapsulated based on the target interface, and the specific service provides a method for setting the cache enable state and the expiration time threshold in the cache configuration information; Furthermore, the interface cache corresponds to multiple interfaces and stores interface data of each interface in isolation.

5. The data reading method according to claim 4, characterized in that: Determining whether the preset interface cache contains the to-be-queried data corresponding to the target interface includes: It is determined whether the data to be queried exists in the interface data of the target interface stored in the interface cache.

6. The data reading method according to claim 1, wherein: The method further comprises: When or after writing the data into the interface cache, recording the start storage time of the data; After determining whether the preset interface cache contains the data to be queried corresponding to the target interface, the storage duration of the data to be queried is obtained by subtracting the start storage time of the data to be queried from the current time.

7. A data reading device, characterized in that: include: A request receiving unit, configured to receive a query request based on a call target interface; a detection unit, configured to: in response to the presence of to-be-queried data corresponding to the target interface in a preset interface cache, detect whether a storage time of the to-be-queried data in the interface cache is greater than an expiration time threshold of the target interface; The reading unit is used to: in response to the storage time being greater than the expiration time threshold, read the data to be queried from the preset database corresponding to the target interface, update the read data to be queried to the interface cache and return it.

8. The data reading device according to claim 7, characterized in that The detection unit is further configured to: After receiving the query request based on calling the target interface, determining whether the target interface has cache enabled according to cache configuration information of the target interface; If enabled, executing the step of determining whether the data to be queried exists in the interface cache; Before detecting whether the storage time of the data to be queried in the interface cache is greater than the expiration time threshold preset for the target interface, the expiration time threshold of the target interface is obtained from the cache configuration information of the target interface.

9. An electronic device, characterized in that: include: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 6.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 6 is implemented.

Citation Information

Patent Citations

  • Data caching device and method

    CN105306457A

  • Data caching method, device and equipment and readable storage medium

    CN112035526A

  • Data processing method and system, computer readable medium and electronic equipment

    CN113010552A