CN116226187A - Data caching method, device, computer equipment and storage medium - Google Patents

Data caching method, device, computer equipment and storage medium Download PDF

Info

Publication number
CN116226187A
CN116226187A CN202211654045.1A CN202211654045A CN116226187A CN 116226187 A CN116226187 A CN 116226187A CN 202211654045 A CN202211654045 A CN 202211654045A CN 116226187 A CN116226187 A CN 116226187A
Authority
CN
China
Prior art keywords
target
cache
interface
data
configuration information
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202211654045.1A
Other languages
Chinese (zh)
Inventor
温奕添
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shenzhen Qianhai Baidi Network Co ltd
Original Assignee
Shenzhen Qianhai Baidi Network Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shenzhen Qianhai Baidi Network Co ltd filed Critical Shenzhen Qianhai Baidi Network Co ltd
Priority to CN202211654045.1A priority Critical patent/CN116226187A/en
Publication of CN116226187A publication Critical patent/CN116226187A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/245Query processing
    • G06F16/2455Query execution
    • G06F16/24552Database cache management
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/25Integrating or interfacing systems involving database management systems
    • G06F16/252Integrating or interfacing systems involving database management systems between a Database Management System and a front-end application
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computational Linguistics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The application relates to a data caching method, a data caching device, computer equipment and a storage medium. The method comprises the following steps: acquiring target configuration information of the service application, wherein the target configuration information comprises a target interface, a path field and a cache update field; and further determining a calling record of the target interface according to the path field, and carrying out update type detection on the cache update field when the calling record characterizes the target interface as being called again, so as to obtain a type detection result. Therefore, when the type detection result is the target type, the cache data can be read from the server cache, and the cache data can be cached to the page cache. By adopting the method, the flexibility of data caching can be improved.

Description

Data caching method, device, computer equipment and storage medium
Technical Field
The present disclosure relates to the field of internet technologies, and in particular, to a data caching method, a data caching device, a computer device, and a storage medium.
Background
With the development of internet technology, more and more resources are required by various service applications, and when the service applications are started, corresponding interfaces are called to acquire cache data, so that data rendering is performed on corresponding pages.
At present, when a service end starts a service application, a plurality of interfaces corresponding to the service application in different stages are determined first, and the interfaces are directly called, so that cache data corresponding to the current stage is obtained. However, the method of directly calling the interface without distinction is adopted without considering the actual calling condition of the interface, and when the calling failure occurs, the cache data required by the corresponding page cannot be obtained. Therefore, how to flexibly perform data caching, and further improve the flexibility of cache data acquisition corresponding to service application.
Disclosure of Invention
In view of the foregoing, it is desirable to provide a data caching method, apparatus, computer device, storage medium, and computer program product that can improve flexibility of data caching.
In a first aspect, the present application provides a data caching method. The method comprises the following steps:
when a service application is started, acquiring target configuration information of the service application; the target configuration information comprises a target interface, a path field and a cache update field;
determining a call record of the target interface according to the path field;
When the call record characterizes the target interface as being called again, the cache update field is subjected to update type detection to obtain a type detection result;
when the type detection result is the target type, reading cache data from a server cache;
caching the cache data to a page cache; the page cache is used for providing cache data associated with a target page of the business application when the target page is displayed.
In one embodiment, before the obtaining the target configuration information of the service application, the method further includes: determining a service module corresponding to the service application; the service module comprises at least one sub-module; acquiring initial configuration information corresponding to the service module; the initial configuration information comprises a plurality of interfaces corresponding to each sub-module and field information corresponding to each interface; and determining target configuration information corresponding to the service application according to the plurality of field information.
In one embodiment, the field information includes interface status and pre-line time; the target configuration information includes a plurality of sub-configuration information; the determining the target configuration information corresponding to the service application according to the field information comprises the following steps: aiming at each field information in a plurality of field information, when the interface state in the current field information is an online state, taking the current field information and a corresponding current interface as sub-configuration information; when the interface state in the current field information is a pre-online state, determining the current time for acquiring the initial configuration information; and if the current time and the pre-online time meet a preset condition, taking the current field information and the corresponding current interface as sub-configuration information.
In one embodiment, after the determining the call record of the target interface according to the path field, the method further includes: when the call record characterizes the target interface as the first call, calling the target interface to read cache data from a database through the target interface; and caching the cache data to the page cache.
In one embodiment, after the update type detection is performed on the cache update field to obtain a type detection result, the method further includes: and when the type detection result is not the target type, calling the target interface to read cache data from a database through the target interface, and caching the cache data to the page cache.
In one embodiment, before the reading of the cache data from the server cache, the method further includes: judging whether cache data corresponding to the target interface exist in the server cache; if not, calling the target interface to read cache data from a database through the target interface, and caching the cache data to the page cache; the reading the cache data from the server cache includes: if yes, the cache data are read from the server cache.
In one embodiment, the target configuration information further includes a valid duration; before the caching of the cached data into the page cache, the method further comprises: according to the effective duration, carrying out validity detection on the cache data to obtain a validity result; when the validity result indicates that the detection is invalid, calling the target interface to read cache data from a database through the target interface, and caching the cache data to the page cache; the caching the cache data into a page cache includes: and caching the cache data into a page cache when the validity result indicates that the detection is valid.
In one embodiment, the invoking the target interface to read cache data from a database through the target interface includes: determining a target data source and an interface type corresponding to the target interface, and determining a data reading mode according to the interface type; and calling the target interface to inquire the target data source in the data reading mode to obtain cache data corresponding to the target interface.
In a second aspect, the present application further provides a data caching apparatus. The device comprises:
The configuration information determining module is used for acquiring target configuration information of the service application when the service application is started; the target configuration information comprises a target interface, a path field and a cache update field;
the updating type detection module is used for determining a calling record of the target interface according to the path field; when the call record characterizes the target interface as being called again, the cache update field is subjected to update type detection to obtain a type detection result;
the cache data determining module is used for reading cache data from the server cache when the type detection result is a target type; caching the cache data to a page cache; the page cache is used for providing cache data associated with a target page of the business application when the target page is displayed.
In a third aspect, the present application also provides a computer device. The computer device comprises a memory storing a computer program and a processor which when executing the computer program performs the steps of:
when a service application is started, acquiring target configuration information of the service application; the target configuration information comprises a target interface, a path field and a cache update field;
Determining a call record of the target interface according to the path field;
when the call record characterizes the target interface as being called again, the cache update field is subjected to update type detection to obtain a type detection result;
when the type detection result is the target type, reading cache data from a server cache;
caching the cache data to a page cache; the page cache is used for providing cache data associated with a target page of the business application when the target page is displayed.
In a fourth aspect, the present application also provides a computer-readable storage medium. The computer readable storage medium has stored thereon a computer program which when executed by a processor performs the steps of:
when a service application is started, acquiring target configuration information of the service application; the target configuration information comprises a target interface, a path field and a cache update field;
determining a call record of the target interface according to the path field;
when the call record characterizes the target interface as being called again, the cache update field is subjected to update type detection to obtain a type detection result;
When the type detection result is the target type, reading cache data from a server cache;
caching the cache data to a page cache; the page cache is used for providing cache data associated with a target page of the business application when the target page is displayed.
In a fifth aspect, the present application also provides a computer program product. The computer program product comprises a computer program which, when executed by a processor, implements the steps of:
when a service application is started, acquiring target configuration information of the service application; the target configuration information comprises a target interface, a path field and a cache update field;
determining a call record of the target interface according to the path field;
when the call record characterizes the target interface as being called again, the cache update field is subjected to update type detection to obtain a type detection result;
when the type detection result is the target type, reading cache data from a server cache;
caching the cache data to a page cache; the page cache is used for providing cache data associated with a target page of the business application when the target page is displayed.
The data caching method, the data caching device, the computer equipment, the storage medium and the computer program product can determine that the target configuration information comprises a target interface, a path field and a cache update field by acquiring the target configuration information of the business application when the business application is started; and further determining a calling record of the target interface according to the path field, and carrying out update type detection on the cache update field when the calling record characterizes the target interface as being called again, so as to obtain a type detection result. Therefore, when the type detection result is the target type, the cache data can be read from the server cache, and the cache data can be cached to the page cache. After determining the call record of the target interface, adopting a corresponding execution process according to different call records, compared with the traditional mode of calling the interface directly without distinction, when the call record characterizes the target interface as calling again, the cache data can be determined according to the type detection result by carrying out update type detection on the cache update field, so that the condition of call failure of the bazaar interface can still be determined, and the flexibility of obtaining the cache data corresponding to the service application is improved; meanwhile, the cache data is read from the server cache only when the type detection result is the target type, so that the accuracy of cache data acquisition is ensured.
In addition, when the business application is started each time, repeated calling of the interface is not needed, development of other codes is not needed for the business application, and when the target page of the business application is displayed through page caching, cache data associated with the target page is directly provided, so that the cache data acquisition efficiency is improved, and the operation efficiency of the business application is also improved.
Drawings
FIG. 1 is an application environment diagram of a data caching method in one embodiment;
FIG. 2 is a flow chart of a data caching method in one embodiment;
FIG. 3 is a schematic diagram of data buffering in one embodiment;
FIG. 4 is a schematic diagram of configuration of initial configuration information in one embodiment;
FIG. 5 is a flow chart of reading cache data according to one embodiment;
FIG. 6 is a block diagram of a data caching apparatus in one embodiment;
fig. 7 is an internal structural diagram of a computer device in one embodiment.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application will be further described in detail with reference to the accompanying drawings and examples. It should be understood that the specific embodiments described herein are for purposes of illustration only and are not intended to limit the present application.
The data caching method provided by the embodiment of the application can be applied to an application environment shown in fig. 1. Wherein the terminal 102 may communicate with the server 104 via a network. The terminal 102 and the server 104 may each independently execute the data caching method provided in the embodiment of the present application, or may cooperatively execute the data caching method provided in the embodiment of the present application. Taking the example that the terminal 102 and the server 104 cooperate to perform the data buffering method as an example, when the terminal 102 starts the service application, the target configuration information of the service application is sent to the server 104. The server 104 is configured to determine a call record of the target interface according to the path field; and when the calling record characterizes the target interface as calling again, carrying out update type detection on the cache update field to obtain a type detection result. The server 104 is further configured to read the cache data from the server cache and cache the cache data to the page cache when the type detection result is the target type, where the page cache is configured to provide the cache data associated with the target page when the terminal 102 presents the target page of the service application. The terminal 102 may be, but not limited to, various personal computers, notebook computers, smartphones, tablet computers, and portable wearable devices, and the server 104 may be implemented as a stand-alone server or a server cluster composed of a plurality of servers.
In one embodiment, as shown in fig. 2, a data caching method is provided, which is executed by a service end, and is described by taking application of the method to a computer device, where the computer device may be a terminal or a server in fig. 1, and includes the following steps:
step 202, when the service application is started, obtaining target configuration information of the service application.
The target configuration information comprises a target interface, a path field and a cache update field; the target interface may be embodied by an apiName interface name field or an apiId interface identification field; the path field may be embodied by an apiUrl field; the cache update field may be embodied by a refreshFlag field, which may be used to ignore the cache mechanism. The target configuration information is determined by the configuration end in response to the configuration operation of the user. Each business application corresponds to an application identification, for example, the application identification is AppId.
Specifically, as shown in fig. 3, fig. 3 is a schematic diagram of data buffering. The method comprises the steps that the computer equipment provides a browser, and when the browser responds to starting operation of a user for service application, pre-configured target configuration information is obtained according to application identification of the service application. When the target interfaces comprise a plurality of target interfaces, the target configuration information comprises a path field and a cache update field which are respectively corresponding to each target interface.
In one embodiment, referring to fig. 3, the service side includes a server and a database, that is, the computer device includes a server and a database. When the computer equipment starts a service application, an information pulling request comprising an application identifier is initiated to a configuration end; and the computer equipment determines target configuration information corresponding to the application identifier according to the application identifier in the information pulling request, and sends the target configuration information to a server of the computer equipment. A server in the computer device may store the target configuration information in a database.
In one embodiment, referring to fig. 3, the computer device further includes a page buffer, where the page buffer may be a Web buffer, and is used to temporarily store Web documents and data, and for applications that need to make a large number of service accesses, the Web buffer may implement a quick response to the access, reduce server delay, and so on.
Step 204, determining the call record of the target interface according to the path field.
Specifically, before the target interface is called, the computer device needs to query whether the cache data corresponding to the target interface has completed the cache configuration according to the path field, so that the call record of the target interface needs to be determined. When the cache data completes the cache configuration or needs to call the target interface, the call record is recorded on the target interface, and related information associated with each call to the target interface is recorded in the call record, such as the call times, call time, whether the call is successful, the configuration state and the like.
And 206, when the call record characterizes the target interface as being called again, performing update type detection on the cache update field to obtain a type detection result.
Specifically, the cache configuration is completed by calling the cache data corresponding to the target interface again, and at this time, the computer equipment needs to detect the update type of the cache update field, so as to determine whether the cache data corresponding to the target interface needs to be forcedly updated.
In one embodiment, after determining the call record of the target interface according to the path field, the method further comprises: when the calling record characterizes the target interface as the first calling, the target interface is called so as to read cache data from the database through the target interface; caching the cache data to a page cache.
Specifically, the initial call characterizes that the cache data corresponding to the target interface has not completed the cache configuration, as shown in fig. 3, so the computer device needs to directly call the target interface to pull the cache data from the database through the target interface. At this time, the computer device can directly cache the pulled cache data into the page cache.
In the embodiment, when the call record characterizes the target interface as the initial call, the cache data obtained when the target interface is called is directly cached in the page cache, so that the cache efficiency of the data is improved; meanwhile, different data caching modes are adopted for different call records, so that the flexibility of data caching is improved.
And step 208, when the type detection result is the target type, reading cache data from the server cache.
Wherein the target type may be a forced update type. Forced updating characterizes the process of updating the cache data for which the cache configuration is completed. The server in the computer device further includes a server cache.
Specifically, the computer device needs to determine whether the cache data corresponding to the target interface exists in the server cache, and if so, the cache data is directly read from the server cache. If the cache data does not exist, the computer equipment directly calls the target interface to read the cache data from the database through the target interface.
In one embodiment, after performing update type detection on the cache update field to obtain a type detection result, the method further includes: and when the type detection result is not the target type, calling a target interface to read cache data from a database through the target interface, and caching the cache data to a page cache.
Specifically, referring to fig. 3, when the type detection result is not a forced update type, that is, is not a target type, the computer device may directly call the target interface to pull the cache data from the database through the target interface. At this time, the computer device can directly cache the pulled cache data into the page cache.
In the embodiment, when the type detection result is not the target type, the cache data obtained when the target interface is called is directly cached in the page cache, so that the efficiency of caching the data is improved; meanwhile, different data caching modes are adopted aiming at different types of detection results, so that the flexibility of data caching is improved.
Step 210, caching the cached data into a page cache.
The page cache is used for providing cache data associated with a target page when the target page of the business application is displayed. The target page characterizes any one of a plurality of pages that are presented when the business application is run.
Specifically, when caching the cache data into the page cache, the computer device may determine a current stage of operation of the service application and a plurality of interfaces associated with the current stage, and further read the cache data associated with the plurality of interfaces from the page cache, and display the plurality of cache data in the target page.
In the data caching method, when the service application is started, the target configuration information of the service application is obtained, and the target configuration information can be determined to comprise a target interface, a path field and a cache update field; and further determining a calling record of the target interface according to the path field, and carrying out update type detection on the cache update field when the calling record characterizes the target interface as being called again, so as to obtain a type detection result. Therefore, when the type detection result is the target type, the cache data can be read from the server cache, and the cache data can be cached to the page cache. After determining the call record of the target interface, adopting a corresponding execution process according to different call records, compared with the traditional mode of calling the interface directly without distinction, when the call record characterizes the target interface as calling again, the cache data can be determined according to the type detection result by carrying out update type detection on the cache update field, so that the condition of call failure of the bazaar interface can still be determined, and the flexibility of obtaining the cache data corresponding to the service application is improved; meanwhile, the cache data is read from the server cache only when the type detection result is the target type, so that the accuracy of cache data acquisition is ensured.
In addition, when the business application is started each time, repeated calling of the interface is not needed, development of other codes is not needed for the business application, and when the target page of the business application is displayed through page caching, cache data associated with the target page is directly provided, so that the cache data acquisition efficiency is improved, and the operation efficiency of the business application is also improved.
In one embodiment, before caching the cache data into the page cache, the method further comprises: according to the effective duration, carrying out effectiveness detection on the cache data to obtain an effectiveness result; when the validity result indicates that the detection is invalid, a target interface is called to read cache data from a database through the target interface, and the cache data is cached to a page cache; caching the cached data to a page cache, comprising: and caching the cache data into the page cache when the validity result indicates that the detection is valid.
The target configuration information comprises effective duration; the validity duration may be embodied by a cacheTime field.
Specifically, when the cache data corresponding to the target interface exists in the server cache, the computer equipment determines the cache duration of the cache data stored in the server cache. Referring to fig. 3, the computer device performs validity detection on the cache data according to the cache duration and the valid duration, and determines that the validity result is valid detection when the cache duration is less than or equal to the valid duration; and when the caching time period is longer than the effective time period, determining that the validity result is invalid. When the validity result represents that the detection is valid, the computer equipment can directly cache the cache data to the page cache; when the validity result indicates that the detection is invalid, the computer equipment calls the target interface to pull the cache data from the database through the target interface, and caches the pulled cache data into the page cache.
In this embodiment, the validity result can be accurately obtained by detecting the validity of the cached data, and further, different data caching modes are adopted to cache the cached data into the page cache according to the validity result, so that the flexibility of data caching is improved.
In one embodiment, the target configuration information further includes a synchronization field corresponding to the target interface, where the synchronization field may be embodied by a synsFlag field, and the synchronization field is used to determine whether to synchronize the cache data corresponding to the target interface from the test environment to the production environment.
In one embodiment, before obtaining the target configuration information of the service application, the method further includes: determining a service module corresponding to the service application; acquiring initial configuration information corresponding to a service module; and determining target configuration information corresponding to the service application according to the plurality of field information.
Wherein the service module comprises at least one sub-module; the initial configuration information comprises a plurality of interfaces corresponding to each sub-module and field information corresponding to each interface; the sub-modules may be viewed as business modules.
Specifically, since each service application generally includes a plurality of service modules, each service module includes a plurality of interfaces and field information corresponding to each interface. Therefore, before the computer device obtains the target configuration information of the service application, the configuration of the newly added service application is completed through the configuration terminal, and then the interface and the field information of the interface in the service module are required to be configured, so as to obtain the initial configuration information corresponding to the service application. Wherein the initial configuration information after configuration takes effect in real time. As shown in fig. 4, fig. 4 is a schematic diagram of the principle of configuring initial configuration information.
The configuration end can comprise a visual configuration interface cache system, wherein the visual configuration interface cache system can flexibly add, modify and delete different interfaces according to user requirements, can set a cache level, a cache duration, a refreshing mechanism and a failure mechanism, and can also configure the pre-online time and the pre-offline time of the interfaces. The information of the system configuration can be cached through the visual configuration interface, and the information can be displayed through field information corresponding to the interface.
However, when the service application is started, the information in the initial configuration information is not necessarily all valid or usable, so that the configuration end needs to screen the initial configuration information according to the field information in the initial configuration information to obtain the target configuration information corresponding to the service application. The configuration terminal sends the target configuration information to the computer equipment and stores the target configuration information to the database through a server in the computer equipment.
In one embodiment, the configuration end may directly send the initial configuration information to the computer device, where the computer device screens the initial configuration information according to field information in the initial configuration information to obtain target configuration information corresponding to the service application.
In one embodiment, the user may also assign a corresponding interface name, such as an order list, order details, etc., to each interface in advance through the configuration end.
In this embodiment, the configuration terminal configures the newly added service application in advance, so that initial configuration information corresponding to the service application can be flexibly obtained, and the initial configuration information can be visually displayed; when the service application is started, the service module corresponding to the service application can be rapidly determined, and the target configuration information is accurately screened from the initial configuration information through a plurality of field information in the service module, so that the execution efficiency of the service application is improved. In addition, the configuration end sends the target configuration information to the computer equipment only when the service application is started, so that the bandwidths of the configuration end and the service end are saved, and the resource consumption cost of the server is reduced.
Meanwhile, the centralized management of the service application is realized by adopting a mode of combining the configuration end and the service end, the whole process of determining and inquiring the whole cache data is realized, the systemization and automation of the whole process of interface configuration, calling, recording and the like are realized, and the efficiency of cache data acquisition is improved.
In one embodiment, determining target configuration information corresponding to a service application according to a plurality of field information includes: aiming at each field information in the plurality of field information, when the interface state in the current field information is the online state, the current field information and the corresponding current interface are used as sub-configuration information; when the interface state in the current field information is the pre-online state, determining the current time for acquiring the initial configuration information; and if the preset condition is met between the current time and the pre-online time, taking the current field information and the corresponding current interface as sub-configuration information.
The field information comprises interface states and pre-online time; the target configuration information includes a plurality of sub-configuration information; the interface states include an on-line state, a pre-on-line state, and an off-line state.
Specifically, taking the screening of the initial configuration information by the computer equipment as an example for explanation, the computer equipment determines the current field information corresponding to the current interface, and if the interface state in the current field information is the off-line state, the current field information cannot be used as the sub-configuration information; and if the interface state in the current field information is the on-state, taking the current field information and the corresponding current interface as sub-configuration information. If the interface state in the current field information is the pre-online state, the computer device needs to determine the current time for acquiring the initial configuration information, and it is easy to understand that the current time is usually earlier than the pre-online time corresponding to the current interface, and if the time difference between the current time and the pre-online time is smaller than the preset threshold value, the current field information and the corresponding current interface can still be used as the sub-configuration information. Therefore, the computer equipment integrates the plurality of sub-configuration information to obtain the screened target configuration information.
In this embodiment, by determining the interface states corresponding to the interfaces, the target configuration information required by the service application during running can be accurately screened, so that unnecessary calling of the interfaces is avoided, and the accuracy of subsequent caching of the cache data is ensured.
In one embodiment, as shown in fig. 5, the target interface is invoked to read cache data from the database through the target interface, comprising the steps of:
step 502, determining a target data source and an interface type corresponding to a target interface, and determining a data reading mode according to the interface type.
The target configuration information also comprises a data source identifier and an interface type corresponding to the target interface; the interface types include database types and script types, which may be Python scripts, PHP scripts, etc.
Specifically, the computer device determines a data source field table corresponding to the data source identifier, wherein the data source field table is obtained by performing configuration operation on the data source identifier in advance, and the data source field table comprises a connection address. Wherein the connection address may be the sqlalchemy_uri field information. Namely, the computer equipment can accurately obtain the target data source from the data warehouse through connecting the address, and the rapid positioning to the position of the target data source in the data warehouse is realized.
Further, the computer device determines an interface type of the target interface, and when the interface type is a database type, the data reading mode is a mode of reading data through SQL query sentences. When the interface type is script type, the data reading mode may be a mode of logging in the remote target container through the target protocol, or may be a mode of directly executing the script code corresponding to the target interface, so that the data reading is completed through the script code.
Step 504, call the target interface to query the target data source in a data reading manner, so as to obtain the cache data corresponding to the target interface.
Specifically, the computer device executes a call to the target interface to trigger the target interface to query the target data source through different data reading modes. When the data reading mode is to directly execute the script code corresponding to the target interface, the script code is configured with a reading path of the target data source associated with the target interface, and when the script code is executed, the target data source can be queried through the script code to obtain cache data corresponding to the target interface.
When the interface type is a database type, the computer equipment can respond to the data reading operation of the user to obtain initial query parameters, and takes the standard format of the target interface as auxiliary parameters; the standard format of the target interface includes, but is not limited to: public interface name {// interface content }, etc. The computer equipment splices the initial query parameters and the auxiliary parameters to obtain target query parameters which accord with the database query format, wherein the target query parameters can be database query SQL sentences. The computer equipment can inquire the target data source through the target inquiry parameters to obtain the cache data corresponding to the target interface.
For the situation that the target data source is deployed in the target container, the computer equipment needs to establish communication connection with the target container through the target protocol in advance. When the computer equipment triggers the target container, the target data source can be queried through the target container which is remotely connected, cache data corresponding to the target interface is obtained, and the cache data is sent to the computer equipment.
In this embodiment, different data reading modes can be determined by determining the interface type corresponding to the target interface, so that flexibility and diversity of reading cache data are improved; the user can flexibly read data in the running process of the business application aiming at the interface type which is a database type, so that corresponding cache data can be displayed flexibly while the business application is running, and the convenience of reading the cache data is improved; aiming at a script type target interface, data query can be realized by providing a remote connection mode, so that isolation and rapid deployment of service application are realized, and the difficulty of interface calling is reduced.
It should be understood that, although the steps in the flowcharts related to the above embodiments are sequentially shown as indicated by arrows, these steps are not necessarily sequentially performed in the order indicated by the arrows. The steps are not strictly limited to the order of execution unless explicitly recited herein, and the steps may be executed in other orders. Moreover, at least some of the steps in the flowcharts described in the above embodiments may include a plurality of steps or a plurality of stages, which are not necessarily performed at the same time, but may be performed at different times, and the order of the steps or stages is not necessarily performed sequentially, but may be performed alternately or alternately with at least some of the other steps or stages.
Based on the same inventive concept, the embodiment of the application also provides a data caching device for implementing the above related data caching method. The implementation of the solution provided by the apparatus is similar to the implementation described in the above method, so the specific limitation in one or more embodiments of the data caching apparatus provided below may refer to the limitation of the data caching method hereinabove, and will not be repeated herein.
In one embodiment, as shown in fig. 6, there is provided a data caching apparatus 600, comprising: a configuration information determination module 602, an update type detection module 604, and a cache data determination module 606, wherein:
a configuration information determining module 602, configured to obtain target configuration information of a service application when the service application is started; the target configuration information includes a target interface, a path field, and a cache update field.
An update type detection module 604, configured to determine a call record of the target interface according to the path field; and when the calling record characterizes the target interface as calling again, carrying out update type detection on the cache update field to obtain a type detection result.
A cache data determining module 606, configured to read cache data from the server cache when the type detection result is a target type; caching the cache data to a page cache; the page cache is used for providing cache data associated with a target page when the target page of the business application is displayed.
In one embodiment, the configuration information determining module 602 is further configured to determine a service module corresponding to a service application; the business module comprises at least one sub-module; acquiring initial configuration information corresponding to a service module; the initial configuration information comprises a plurality of interfaces corresponding to each sub-module and field information corresponding to each interface; and determining target configuration information corresponding to the service application according to the plurality of field information.
In one embodiment, the configuration information determining module 602 is further configured to, for each of the plurality of field information, use the current field information and the corresponding current interface as the sub-configuration information when the interface state in the current field information is the online state; when the interface state in the current field information is the pre-online state, determining the current time for acquiring the initial configuration information; and determining the difference between the current time and the pre-online time, and taking the current field information and the corresponding current interface as sub-configuration information when the difference accords with a preset condition.
In one embodiment, the update type detection module 604 is further configured to call the target interface to read the cache data from the database through the target interface when the call record characterizes the target interface as the first call; caching the cache data to a page cache.
In one embodiment, the update type detection module 604 is further configured to call the target interface to read the cache data from the database through the target interface and cache the cache data to the page cache when the type detection result is not the target type.
In one embodiment, the data caching apparatus 600 further includes a validity detection module 608, configured to perform validity detection on the cached data according to the validity duration, so as to obtain a validity result; when the validity result indicates that the detection is invalid, a target interface is called to read cache data from a database through the target interface, and the cache data is cached to a page cache; and caching the cache data into the page cache when the validity result indicates that the detection is valid.
In one embodiment, the data caching apparatus 600 further includes an interface calling module 610, configured to determine a target data source and an interface type corresponding to the target interface, and determine a data reading manner according to the interface type; and calling the target interface to inquire the target data source in a data reading mode to obtain cache data corresponding to the target interface.
The modules in the data caching apparatus may be implemented wholly or partly by software, hardware, or a combination thereof. The above modules may be embedded in hardware or may be independent of a processor in the computer device, or may be stored in software in a memory in the computer device, so that the processor may call and execute operations corresponding to the above modules.
In one embodiment, a computer device is provided, which may be a terminal, and the internal structure of which may be as shown in fig. 7. The computer device includes a processor, a memory, an Input/Output interface (I/O), a communication interface, a display unit, and an Input device. The processor, the memory and the input/output interface are connected through a system bus, and the communication interface, the display unit and the input device are connected to the system bus through the input/output interface. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage media. The input/output interface of the computer device is used to exchange information between the processor and the external device. The communication interface of the computer device is used for carrying out wired or wireless communication with an external terminal, and the wireless mode can be realized through WIFI, a mobile cellular network, NFC (near field communication) or other technologies. The computer program is executed by a processor to implement a data caching method. The display unit of the computer equipment is used for forming a visual picture, and can be a display screen, a projection device or a virtual reality imaging device, wherein the display screen can be a liquid crystal display screen or an electronic ink display screen, the input device of the computer equipment can be a touch layer covered on the display screen, can also be a key, a track ball or a touch pad arranged on a shell of the computer equipment, and can also be an external keyboard, a touch pad or a mouse and the like.
It will be appreciated by those skilled in the art that the structure shown in fig. 7 is merely a block diagram of a portion of the structure associated with the present application and is not intended to limit the computer device to which the present application is applied, and that a particular computer device may include more or fewer components than shown, or may combine certain components, or have a different arrangement of components.
In one embodiment, there is also provided a computer device including a memory and a processor, the memory storing a computer program, the processor implementing the steps of the method embodiments described above when executing the computer program.
In one embodiment, a computer-readable storage medium is provided, storing a computer program that, when executed by a processor, performs the steps of the method embodiments described above.
In one embodiment, a computer program product or computer program is provided that includes computer instructions stored in a computer readable storage medium. The processor of the computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device performs the steps in the above-described method embodiments.
Those skilled in the art will appreciate that implementing all or part of the above-described embodiment methods may be accomplished by way of a computer program that instructs associated hardware to perform the method, and that the computer program may be stored on a non-volatile computer readable storage medium, which when executed, may comprise the embodiment flows of the above-described methods. Any reference to memory, database, or other medium used in the various embodiments provided herein may include at least one of non-volatile and volatile memory. The nonvolatile Memory may include Read-Only Memory (ROM), magnetic tape, floppy disk, flash Memory, optical Memory, high density embedded nonvolatile Memory, resistive random access Memory (ReRAM), magnetic random access Memory (Magnetoresistive Random Access Memory, MRAM), ferroelectric Memory (Ferroelectric Random Access Memory, FRAM), phase change Memory (Phase Change Memory, PCM), graphene Memory, and the like. Volatile memory can include random access memory (Random Access Memory, RAM) or external cache memory, and the like. By way of illustration, and not limitation, RAM can be in the form of a variety of forms, such as static random access memory (Static Random Access Memory, SRAM) or dynamic random access memory (Dynamic Random Access Memory, DRAM), and the like. The databases referred to in the various embodiments provided herein may include at least one of relational databases and non-relational databases. The non-relational database may include, but is not limited to, a blockchain-based distributed database, and the like. The processors referred to in the embodiments provided herein may be general purpose processors, central processing units, graphics processors, digital signal processors, programmable logic units, quantum computing-based data processing logic units, etc., without being limited thereto.
The technical features of the above embodiments may be arbitrarily combined, and all possible combinations of the technical features in the above embodiments are not described for brevity of description, however, as long as there is no contradiction between the combinations of the technical features, they should be considered as the scope of the description.
The foregoing examples represent only a few embodiments of the present application, which are described in more detail and are not thereby to be construed as limiting the scope of the present application. It should be noted that it would be apparent to those skilled in the art that various modifications and improvements could be made without departing from the spirit of the present application, which would be within the scope of the present application. Accordingly, the scope of protection of the present application shall be subject to the appended claims.

Claims (11)

1. A method of caching data, the method comprising:
when a service application is started, acquiring target configuration information of the service application; the target configuration information comprises a target interface, a path field and a cache update field;
determining a call record of the target interface according to the path field;
when the call record characterizes the target interface as being called again, the cache update field is subjected to update type detection to obtain a type detection result;
When the type detection result is the target type, reading cache data from a server cache;
caching the cache data to a page cache; the page cache is used for providing cache data associated with a target page of the business application when the target page is displayed.
2. The method of claim 1, wherein prior to the obtaining the target configuration information for the business application, the method further comprises:
determining a service module corresponding to the service application; the service module comprises at least one sub-module;
acquiring initial configuration information corresponding to the service module; the initial configuration information comprises a plurality of interfaces corresponding to each sub-module and field information corresponding to each interface;
and determining target configuration information corresponding to the service application according to the plurality of field information.
3. The method of claim 2, wherein the field information includes an interface state and a pre-line time; the target configuration information includes a plurality of sub-configuration information; the determining the target configuration information corresponding to the service application according to the field information comprises the following steps:
Aiming at each field information in a plurality of field information, when the interface state in the current field information is an online state, taking the current field information and a corresponding current interface as sub-configuration information;
when the interface state in the current field information is a pre-online state, determining the current time for acquiring the initial configuration information;
and if the current time and the pre-online time meet a preset condition, taking the current field information and the corresponding current interface as sub-configuration information.
4. The method of claim 1, wherein after said determining the call record for the target interface from the path field, the method further comprises:
when the call record characterizes the target interface as the first call, calling the target interface to read cache data from a database through the target interface;
and caching the cache data to the page cache.
5. The method according to claim 1, wherein after said performing update type detection on said cache update field to obtain a type detection result, the method further comprises:
and when the type detection result is not the target type, calling the target interface to read cache data from a database through the target interface, and caching the cache data to the page cache.
6. The method of claim 1, wherein the target configuration information further comprises a valid duration; before the caching of the cached data into the page cache, the method further comprises:
according to the effective duration, carrying out validity detection on the cache data to obtain a validity result;
when the validity result indicates that the detection is invalid, calling the target interface to read cache data from a database through the target interface, and caching the cache data to the page cache;
the caching the cache data into a page cache includes:
and caching the cache data into a page cache when the validity result indicates that the detection is valid.
7. The method of any of claims 4 to 6, wherein the invoking the target interface to read cached data from a database via the target interface comprises:
determining a target data source and an interface type corresponding to the target interface, and determining a data reading mode according to the interface type;
and calling the target interface to inquire the target data source in the data reading mode to obtain cache data corresponding to the target interface.
8. A data caching apparatus, the apparatus comprising:
the configuration information determining module is used for acquiring target configuration information of the service application when the service application is started; the target configuration information comprises a target interface, a path field and a cache update field;
the updating type detection module is used for determining a calling record of the target interface according to the path field; when the call record characterizes the target interface as being called again, the cache update field is subjected to update type detection to obtain a type detection result;
the cache data determining module is used for reading cache data from the server cache when the type detection result is a target type; caching the cache data to a page cache; the page cache is used for providing cache data associated with a target page of the business application when the target page is displayed.
9. A computer device comprising a memory and a processor, the memory storing a computer program, characterized in that the processor implements the steps of the method of any of claims 1 to 7 when the computer program is executed.
10. A computer readable storage medium, on which a computer program is stored, characterized in that the computer program, when being executed by a processor, implements the steps of the method of any of claims 1 to 7.
11. A computer program product comprising a computer program, characterized in that the computer program, when being executed by a processor, implements the steps of the method of any of claims 1 to 7.
CN202211654045.1A 2022-12-22 2022-12-22 Data caching method, device, computer equipment and storage medium Pending CN116226187A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211654045.1A CN116226187A (en) 2022-12-22 2022-12-22 Data caching method, device, computer equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211654045.1A CN116226187A (en) 2022-12-22 2022-12-22 Data caching method, device, computer equipment and storage medium

Publications (1)

Publication Number Publication Date
CN116226187A true CN116226187A (en) 2023-06-06

Family

ID=86586281

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211654045.1A Pending CN116226187A (en) 2022-12-22 2022-12-22 Data caching method, device, computer equipment and storage medium

Country Status (1)

Country Link
CN (1) CN116226187A (en)

Similar Documents

Publication Publication Date Title
KR101644666B1 (en) Programming model for synchronizing browser caches across devices and web services
US8745164B2 (en) Method and system to detect a cached web page
US9183072B1 (en) Error troubleshooting using a correlated knowledge base
WO2019019670A1 (en) Application accessing method and device, computer apparatus, and storage medium
CN113064919A (en) Data processing method, data storage system, computer device and storage medium
US10275468B2 (en) Replication of data in a distributed file system using an arbiter
CN110008261B (en) External change detection
CN110008423B (en) Off-line processing method of dynamic webpage, output terminal and storage medium
CN116226187A (en) Data caching method, device, computer equipment and storage medium
CN117435215A (en) Development environment deployment method, system, computer device and storage medium
CN114756293A (en) Service processing method, device, computer equipment and storage medium
US11256574B1 (en) Method and system for backing up cloud native and non-cloud native applications
US8655910B1 (en) Methods and systems for coupling client-side and server-side persistence frameworks
CN114528045B (en) Plug-in operation method, device, computer equipment and storage medium
CN114036171B (en) Application data management method, device, computer equipment and storage medium
CN116541145A (en) Data calling method, device, computer equipment and computer storage medium
CN117807334A (en) First screen page display method and device, computer equipment and storage medium
CN117331625A (en) Page resource loading method and device, computer equipment and storage medium
CN117056220A (en) Batch job testing method and device, computer equipment and storage medium
CN114915573A (en) Test method, device, equipment, storage medium and program product
CN117834604A (en) Communication method, device, computer equipment and storage medium based on B/S architecture
CN117032779A (en) Application version switching method, device, computer equipment and storage medium
CN116432229A (en) Browser screen capture prevention method, device, computer equipment, medium and program product
CN117435569A (en) Dynamic capacity expansion method, device, equipment, medium and program product for cache system
CN116662143A (en) Test method, apparatus, device, storage medium and computer program product

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination