CN116226189A - Cache data query method, device, electronic equipment and computer readable medium - Google Patents

Cache data query method, device, electronic equipment and computer readable medium Download PDF

Info

Publication number
CN116226189A
CN116226189A CN202211698131.2A CN202211698131A CN116226189A CN 116226189 A CN116226189 A CN 116226189A CN 202211698131 A CN202211698131 A CN 202211698131A CN 116226189 A CN116226189 A CN 116226189A
Authority
CN
China
Prior art keywords
cache
data
database
information
data query
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
CN202211698131.2A
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.)
Dmall Life China Network Technology Co ltd
Original Assignee
Dmall Life China Network Technology 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 Dmall Life China Network Technology Co ltd filed Critical Dmall Life China Network Technology Co ltd
Priority to CN202211698131.2A priority Critical patent/CN116226189A/en
Publication of CN116226189A publication Critical patent/CN116226189A/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/22Indexing; Data structures therefor; Storage structures
    • G06F16/2282Tablespace storage structures; Management thereof
    • 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/2453Query optimisation
    • 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
    • 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/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
    • 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)
  • Theoretical Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computational Linguistics (AREA)
  • Computing Systems (AREA)
  • Software Systems (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The embodiment of the disclosure discloses a cache data query method, a cache data query device, electronic equipment and a computer readable medium. One embodiment of the method comprises the following steps: receiving a database data query statement corresponding to a data query request; acquiring label information corresponding to the database data query statement based on the database data query statement; based on the tag information, obtaining a cache result of the corresponding tag information from the associated remote distributed cache; determining whether the cache result contains cache data; in response to determining that the cache result does not contain cache data, acquiring target data corresponding to the tag information from the associated database; and sending the target data to the terminal equipment of the database user corresponding to the data query request. According to the embodiment, the hit rate of the data in the database user query cache can be improved, the development steps of a developer are simplified, the development difficulty of the developer is reduced, and the time consumption is shortened.

Description

Cache data query method, device, electronic equipment and computer readable medium
Technical Field
Embodiments of the present disclosure relate to the field of computer technology, and in particular, to a method, an apparatus, an electronic device, and a computer readable medium for querying cache data.
Background
The data is read through the read-write mode of the combination of the database and the cache, so that the high concurrency and low delay performance of the system can be ensured. Currently, when data is read, the following methods are generally adopted: and generating tag information corresponding to the database data query statement through the application program, and performing reading operation on the remote distributed cache or the database.
However, the inventors found that when the data is read in the above manner, there are often the following technical problems:
firstly, tag information is generated according to text content of database data query sentences, and tag information generated according to database data query sentences with the same semantics but different texts is possibly inconsistent, so that more tag information generated according to database data query sentence texts is inconsistent with tag information stored in a cache and generated according to historical database data query sentence texts, and the hit rate of data in a database user query cache is low; when the application program is added with the function points, the developer needs to develop according to the fixed processing logic again, namely, the developer needs to adapt to the access mode of the database and the cache middleware according to the upper service system, so that the development difficulty of the developer is high, the operation steps are complex, and the time consumption is long.
Secondly, when some database query data sentences with higher query frequency are queried through the application program, the cache is not preheated or is preheated only according to the text content of the database query sentences, no data corresponding to the database query data sentences with higher query frequency exist in the cache, and the application program needs to repeatedly query the data of the database and write the data into the cache. Resulting in a smaller hit rate for the database user to query the data in the cache.
The above information disclosed in this background section is only for enhancement of understanding of the background of the inventive concept and, therefore, may contain information that does not form the prior art that is already known to those of ordinary skill in the art in this country.
Disclosure of Invention
The disclosure is in part intended to introduce concepts in a simplified form that are further described below in the detailed description. The disclosure is not intended to identify key features or essential features of the claimed subject matter, nor is it intended to be used to limit the scope of the claimed subject matter.
Some embodiments of the present disclosure propose a cache data query method, apparatus, electronic device, and computer readable medium to solve one or more of the technical problems mentioned in the background section above.
In a first aspect, some embodiments of the present disclosure provide a method for querying cached data, the method comprising: receiving a database data query statement corresponding to a data query request; acquiring label information corresponding to the database data query statement based on the database data query statement; based on the tag information, obtaining a cache result of the corresponding tag information from the associated remote distributed cache; determining whether the cache result contains cache data; in response to determining that the cache result does not contain cache data, acquiring target data corresponding to the tag information from the associated database; and sending the target data to the terminal equipment of the database user corresponding to the data query request.
In a second aspect, some embodiments of the present disclosure provide a cached data query device, the device comprising: a receiving unit configured to receive a database data query statement corresponding to a data query request; the first acquisition unit is configured to acquire tag information corresponding to the database data query statement based on the database data query statement; a second acquisition unit configured to acquire a cache result of the corresponding tag information from the associated remote distributed cache based on the tag information; a determination unit configured to determine whether the cache result contains cache data; a third acquisition unit configured to acquire target data corresponding to the tag information from the associated database in response to determining that the cache data is not included in the cache result; and the sending unit is configured to send the target data to the terminal equipment of the database user corresponding to the data query request.
In a third aspect, some embodiments of the present disclosure provide an electronic device comprising: one or more processors; a storage device having one or more programs stored thereon, which when executed by one or more processors causes the one or more processors to implement the method described in any of the implementations of the first aspect above.
In a fourth aspect, some embodiments of the present disclosure provide a computer readable medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the method described in any of the implementations of the first aspect above.
The above embodiments of the present disclosure have the following advantageous effects: according to the cache data query method of some embodiments of the present disclosure, the hit rate of the database user for querying the data in the cache is improved, the development difficulty of a developer is reduced, the development operation steps are simplified, and the time consumption is shortened. Specifically, the hit rate of the data in the database user query cache is low, the development difficulty of a developer is high, the operation steps are complicated, and the time consumption is long because: the tag information is generated according to the text content of the database data query statement, and the tag information generated according to the database data query statement with the same semantic meaning but different text is possibly inconsistent, so that the tag information generated according to the database data query statement text is more inconsistent with the tag information stored in the cache and generated according to the historical database data query statement text, and the hit rate of the data in the database user query cache is lower; when the application program is added with the function points, the developer needs to develop according to the fixed processing logic again, namely, the developer needs to adapt to the access mode of the database and the cache middleware according to the upper service system, so that the development difficulty of the developer is high, the operation steps are complex, and the time consumption is long. Based on this, the cache data query method of some embodiments of the present disclosure first receives a database data query statement corresponding to a data query request. Thus, a database data query statement may characterize a query statement for querying data. Then, based on the database data query statement, the tag information of the corresponding database data query statement is acquired. Thus, the label information corresponding to the semantics of the database data query statement can be obtained, and the label information can characterize the semantics of the database data query statement. And then, based on the tag information, obtaining a cache result of the corresponding tag information from the associated remote distributed cache. Thereby, cache data corresponding to the tag information can be acquired. Next, it is determined whether the cached data is contained in the cached results. Thus, it can be determined whether or not cache data corresponding to tag information exists in the cache. Then, in response to determining that the cache result does not contain cache data, target data corresponding to the tag information is acquired from the associated database. Thereby, data corresponding to the tag information can be acquired. And finally, sending the target data to the terminal equipment of the database user corresponding to the data query request. Thus, the database user corresponding to the data query request can acquire the data corresponding to the data query request. Also because the tag information is generated from the semantics of the database query data statement, not just from the text content of the database query statement. Thus, when there are two query sentences whose text contents are different but whose semantics are identical, the generated tag information is identical. The label information of the database data query statement can be ensured to be consistent with the label information of the corresponding previous database data query statement in the cache. Therefore, the hit rate of the data in the database user query cache can be improved. And because only the database statement corresponding to the database user request information is required to be sent and the feedback information corresponding to the database statement is received, the number of times that a developer configures the access mode of the database and the cache middleware is reduced, the development difficulty of the developer is reduced, the operation steps are simplified, and the time consumption is shortened. Therefore, the hit rate of the data in the database user query cache is improved, and the development difficulty of a developer is simplified.
Drawings
The above and other features, advantages, and aspects of embodiments of the present disclosure will become more apparent by reference to the following detailed description when taken in conjunction with the accompanying drawings. The same or similar reference numbers will be used throughout the drawings to refer to the same or like elements. It should be understood that the figures are schematic and that elements and components are not necessarily drawn to scale.
FIG. 1 is a flow chart of some embodiments of a cached data query method according to the present disclosure;
FIG. 2 is a schematic diagram of some embodiments of a cache data querying device according to the present disclosure;
fig. 3 is a schematic structural diagram of an electronic device suitable for use in implementing some embodiments of the present disclosure.
Detailed Description
Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. While certain embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure may be embodied in various forms and should not be construed as limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete. It should be understood that the drawings and embodiments of the present disclosure are for illustration purposes only and are not intended to limit the scope of the present disclosure.
It should be noted that, for convenience of description, only the portions related to the present invention are shown in the drawings. Embodiments of the present disclosure and features of embodiments may be combined with each other without conflict.
It should be noted that the terms "first," "second," and the like in this disclosure are merely used to distinguish between different devices, modules, or units and are not used to define an order or interdependence of functions performed by the devices, modules, or units.
It should be noted that references to "one", "a plurality" and "a plurality" in this disclosure are intended to be illustrative rather than limiting, and those of ordinary skill in the art will appreciate that "one or more" is intended to be understood as "one or more" unless the context clearly indicates otherwise.
The names of messages or information interacted between the various devices in the embodiments of the present disclosure are for illustrative purposes only and are not intended to limit the scope of such messages or information.
The present disclosure will be described in detail below with reference to the accompanying drawings in conjunction with embodiments.
Fig. 1 illustrates a flow 100 of some embodiments of a cached data query method according to the present disclosure. The cache data query method comprises the following steps:
Step 101, receiving a database data query statement corresponding to a data query request.
In some embodiments, an executing body (e.g., computing device) of a cache data query method may receive a database data query statement corresponding to a data query request. The data query request may be request information for obtaining data in the database. The database data query statement may be a statement for querying data in the database. In practice, the execution body may receive a database data query statement sent by an application program. It should be noted that, in the embodiment of the present disclosure, the data is queried and written into the cache system by using standard database statements, so that the cache system data and the write-in data can be obtained more flexibly.
Optionally, before step 101, first, the execution body may further receive a database data write statement corresponding to the data write request. The data writing request may be request information for writing data into a database. The database data writing statement may be a statement for writing data into the database. In practice, the execution body may receive a database data write statement sent by an application program. Thus, a database data write statement corresponding to the data write request can be received. Thus, data corresponding to the database data writing statement can be written to the database.
Then, tag list information corresponding to the database data writing sentence may be acquired based on the database data writing sentence. The tag list information may characterize a set of tag information corresponding to the data table name information. The data table name information may be the name of the data table of the database statement corresponding to the standard. For example, the data table name information may be "table_user". The tag information may characterize the semantics of the database data query statement. For example, the tag information may be "3ffa6ce7703df731". One data table name information may correspond to a plurality of tag information. In practice, first, the execution body may call the task thread pool component to obtain a new execution thread. The task thread pool component may be a component for storing thread resources required for executing tasks such as database statement requests at the front end and heartbeat detection with a data source. Then, according to the execution thread, the execution component can be called to perform the data writing operation. The execution component may be a component that connects each component in series and schedules a query data flow and a write data flow. And secondly, calling the database statement analyzing component through the executing component to call an explatin interface of the database so as to acquire a physical executing statement corresponding to the database data writing statement. For example, the displain interface of the database may be, but is not limited to, one of the following: the StarRocks ' displain interface, mySQL 8.0 ' displain analysis interface, and Oracle's displain plan for interface. The database statement parsing component may parse a database statement into an abstract syntax tree or a physical execution plan. Next, according to the physical execution statement, the database statement parsing component may be called by the execution component to obtain data table name information corresponding to the database data writing statement. And finally, according to the data table name information, calling a cache metadata component through the execution component to acquire tag list information corresponding to the data table name information. The cache metadata component may be a component for storing data table name information and tag information related in a database data query statement. Thus, the tag list information corresponding to the data table name information of the corresponding database data writing sentence can be obtained. Thus, it can be used to update the cache metadata.
Second, each query result cache information corresponding to the tag list information may be deleted from the associated remote distributed cache to update the remote distributed cache. The query result cache information in the query result cache information may include tag information and query data. The remote distributed cache can be an extension of the traditional cache concept, and can place data in local temporary storage for quick retrieval. The query result cache information may be a query result composed of tag information and query data corresponding to the data table name information stored in the remote distributed cache. In practice, first, the execution body may call a cache link pool component through the execution component to obtain link information corresponding to the remote distributed cache. The buffer memory link pool component can maintain a link pool with a buffer memory system for the inside, and can acquire the link pool from the buffer memory link pool component when the buffer memory system needs to be called. And then, the cache plug-in can be called through the link information and the execution component to acquire interface information of the remote distributed cache, and query result cache information corresponding to the data table name information in the remote distributed cache is deleted. The cache plug-in can be a common abstraction of various cache access interfaces, and a concrete cache calling mode can be expanded by realizing the abstraction. For example, the Cache plug-in may be a Cache plug in. It should be noted that, the invention point of the embodiment of the present disclosure is a novel distributed cache system installed on a database, when the execution body calls a cache system interface, the execution body may directly call the cache plug-in by calling the execution component to obtain interface information of a corresponding cache system, and no consideration is required to call the cache system how the bottom layer is implemented, and the cache system may be, but is not limited to, one of the following: redis, memCache, tair. If the cache system type is changed, the whole query or write process is not affected. The cache plug-in can call various types of cache system interface information, so that the novel distributed cache system has strong flexibility. If the cache plug-in is replaced in the operation of the novel distributed cache system, the replacement can be realized by a ClassLoader reloading technology or an SPI mechanism. The novel distributed cache system is integrally designed in a plug-in mode, and the database and the cache system are pluggable and irrelevant to specific middleware type selection, so that the novel distributed cache system can be flexibly expanded. Thus, the remote distributed cache may be updated.
Then, the tag list information corresponding to the database data writing statement in the cache metadata can be deleted so as to update the cache metadata. The cache metadata may be composed of data table name information and tag information corresponding to the data table name information. In practice, the execution body may call the cache metadata component through the execution component to delete tag list information. Thereby, the cache metadata can be updated.
The database data write statement may then be sent to the associated database to update the database. For example, the above-described associated database may be, but is not limited to, one of the following: mysql database, sqlserver database. Thus, the database can be updated according to the database data write statement.
Finally, the update success information corresponding to the database can be sent to the terminal equipment of the database user corresponding to the data writing request. The terminal device may be a computer. Thus, the database user corresponding to the data write request can receive feedback information corresponding to the data write request.
Step 102, obtaining label information of the corresponding database data query statement based on the database data query statement.
In some embodiments, the executing entity may obtain tag information corresponding to the database data query statement based on the database data query statement. In practice, the executing body may obtain the tag information of the corresponding database data query statement based on the database data query statement in various manners.
In some optional implementations of some embodiments, the executing entity may obtain tag information corresponding to the database data query statement based on the database data query statement by:
the first step is to convert the database data query statement into a physical execution statement. Wherein, the physical execution statement may be a statement that characterizes the semantics of the database data query statement. The physical execution statement may be a statement corresponding to a physical execution plan. In practice, first, the execution body may call the task thread pool component to obtain the execution thread corresponding to the database data query statement. The execution component is then invoked to query the database data query statement. And finally, calling the database statement analyzing component through the executing component to call an explatin interface of the database so as to acquire a physical executing statement corresponding to the database data query statement.
And a second step of generating a physical execution tag corresponding to the database data query statement according to the physical execution statement. The physical execution tag may be a tag that characterizes semantics of the database query statement. In practice, first, the execution body may call a cache tag component through the execution component to generate a physical execution tag corresponding to the character string. The cache tag component may be a component for generating a physical execution tag. For example, the cache tag component may generate the physical execution tag by using an MD5 algorithm, where the MD5 algorithm may be a cryptographic hash function that may be used to ensure complete consistency of information transmission. Thus, the physical execution tag corresponding to the database data query statement can be acquired. May be used to query cache data in a remote distributed cache.
And thirdly, determining the physical execution tag as tag information. Thus, the tag information corresponding to the database data query statement can be acquired. May be used to obtain data corresponding thereto.
Step 103, based on the tag information, obtaining a cache result of the corresponding tag information from the associated remote distributed cache.
In some embodiments, the executing entity may obtain the cached results corresponding to the tag information from the associated remote distributed caches based on the tag information. In practice, the execution body may obtain the cache result of the corresponding tag information from the associated remote distributed cache based on the tag information in various manners.
In some optional implementations of some embodiments, the executing entity may obtain the cached result of the corresponding tag information from the associated remote distributed cache based on the tag information by:
and step one, acquiring the link information of the cache system according to the tag information. The cache system link information may represent a link connecting the cache system. Different cache systems correspond to different cache system link information. The cache system link information may include a cache system link. The cache system links described above may be used to connect cache systems. In practice, the execution body may call the cache link pool component through the execution component to obtain cache link information. Thus, can be used to obtain data in a remote distributed cache.
And step two, obtaining a caching result corresponding to the tag information according to the caching system link information and the interface information corresponding to the remote distributed cache. In practice, the execution body may call the interface corresponding to the interface information through the execution component to obtain the cache result corresponding to the tag information in the remote distributed cache. The cache result may be empty or may include cache data. The cache result may represent whether data corresponding to the database data query statement exists in the remote distributed cache. Wherein, the remote distributed cache may be, but is not limited to, one of the following: redis, memCache, tair distributed caching system. Thus, the cache result of the corresponding database data query statement can be obtained.
Step 104, determining whether the cache result contains cache data.
In some embodiments, the execution body may determine whether the cached data is included in the cached results. For example, a buffer result being empty may indicate that no buffer data is contained. The cache result may be indicative of the inclusion of cache data when not empty. In practice, the execution body may call the interface corresponding to the interface information through the execution component to determine whether the cached data exists in the cached result.
Optionally, after step 104, the executing body may further send, in response to determining that the cache result includes cache data corresponding to the tag information, the cache data to a terminal device of the database user corresponding to the data query request. Thus, a database user corresponding to a data query request may receive data corresponding to the data query request.
In step 105, in response to determining that the cache result does not include cache data, target data corresponding to the tag information is acquired from the associated database.
In some embodiments, the executing entity may obtain the target data corresponding to the tag information from the associated database in response to determining that the cache result does not include the cache data. The target data may be data queried according to the database data query statement.
In some optional implementations of some embodiments, the executing entity may send the database data query statement to the database to obtain the target data corresponding to the tag information. In practice, firstly, the execution body may call the query interface corresponding to the database through the execution component. And then, the database data query statement is sent to the database to acquire target data corresponding to the tag information. Thereby, data corresponding to the database data query statement can be acquired.
And step 106, the target data is sent to the terminal equipment of the database user corresponding to the data query request.
In some embodiments, the executing entity may send the target data to a terminal device of a database user corresponding to the data query request.
Optionally, before step 106, first, the executing body may further determine data table name information corresponding to the database data query statement according to the database data query statement. Thereby, it can be used to determine the cache metadata corresponding to the data table name information.
It may then be determined whether the cached metadata set contains cached metadata corresponding to the data table name information described above. The cache metadata in the cache metadata set may be composed of data table name information and tag information. Thus, it can be used to update the cache metadata.
Finally, in response to determining that the cache metadata set includes cache metadata corresponding to the data table name information, the tag information may be added to the cache metadata corresponding to the data table name information to update the cache metadata set. In practice, the executing body may add the tag information to the cache metadata corresponding to the tag information in response to determining that the cache metadata set includes the cache metadata corresponding to the data table name information. Thereby, the cache metadata can be updated.
Optionally, after determining whether the cache metadata set includes cache metadata corresponding to the data table name information, the executing body may first combine the tag information and the data table name information into cache metadata in response to determining that the cache metadata set does not include cache metadata corresponding to the data table name information. In practice, first, the executing body may further determine data table name information and tag information corresponding to the database data query statement in response to determining that the cache metadata set does not include the cache metadata corresponding to the data table name information. Then, the tag information and the data table name information are combined into cache metadata. The data table name information may correspond to a plurality of tag information. The cache metadata may include one or more tag information. Thus, the cache metadata set may be updated by the combined cache metadata.
Then, the cache metadata is added to the cache metadata set to update the cache metadata set. Thus, the cached metadata set may be updated.
Optionally, before step 106, first, the executing entity may further combine the target data and the tag information into a query result. The query result may be data corresponding to the database data query statement.
Then, it may be determined whether there are individual database data query statements in the log component information that satisfy the preset query condition. The log component information may characterize a component storing historical database data query statements. The component storing the historical database data query statement may be a log component. The log component may be a component that stores historical database data query statements. The above-mentioned preset query condition may be that the descending order sequence number of the query frequency of the database data query statement in the preset time period is smaller than the first preset sequence number. In practice, first, the execution body may classify the historical database data query statements stored in the log component to obtain each set of historical database data query statements. Then, each historical database data query statement meeting the preset condition can be selected from each historical database data query statement set in the historical database data query statement set. Then, each selected historical database data query statement is determined to be a target set of historical database data query statements. And then, determining each target historical database data query statement meeting the preset query condition from the target historical database data query statement set. And finally, determining the target historical database data query sentences as database data query sentences. Specifically, a clustering algorithm may be employed to classify historical database data query statements. For example, the clustering algorithm may be a k-means algorithm. The first preset sequence number may be 100. The preset condition may be that a descending order sequence number of query frequencies of the historical database data query sentences in a preset time period is smaller than a second preset sequence number. The second preset sequence number may be 10. Here, specific settings of the first preset sequence number and the second preset sequence number are not limited. Therefore, the method can be used for acquiring each database data query statement meeting the preset query conditions.
Then, in response to determining that each database data query statement meeting the preset query condition exists in the log component information, the each database data query statement can be determined to be a target database data query statement set. In practice, first, the execution body may determine each database data query statement as a target database data query statement in response to determining that there are respective database data query statements satisfying a preset query condition in the log component information. Each target database data query statement may then be determined as a set of target database data query statements. Thus, it can be used to update remote distributed caches.
And secondly, updating the remote distributed cache according to the target database data query statement set. In practice, the target database data query statement may be queried to update the remote distributed cache.
Then, for each target database data query statement in the set of target database data query statements, the following steps may be performed:
and a first sub-step of inquiring the target database data inquiry statement according to a preset time interval. In practice, first, the execution body may query the target database data query statement with a preset time interval as a period. For example, the preset time interval may be, but is not limited to, one of the following: every minute, every hour. It should be noted that, the flow of querying the target database data query statement is identical to the query flow of the database data query statement, and therefore, the description thereof is omitted here. Thus, the target database data query statement can be queried at a certain time interval. Thus, remote distributed caches may be continually updated.
And a second sub-step of determining target tag information and target data table name information corresponding to the target database data query statement according to the target database data query statement. In practice, first, the execution body may call the cache tag component through the execution component to obtain the target tag information corresponding to the target database data query statement. Then, the database statement parsing component may be invoked by the executing component to obtain target data table name information corresponding to the target database data query statement. Thus, the method can be used for updating the cache metadata set and the remote distributed cache.
And a third sub-step of adding the target tag information to the cache metadata corresponding to the target data table name information to update the cache metadata set in response to determining that the cache metadata corresponding to the target data table name information exists in the cache metadata set. Thus, the cached metadata set may be updated. It should be noted that, the flow of updating the cached metadata set by the target data table name information and the target tag information is identical to the flow of updating the cached metadata by the tag information and the data table name information, and therefore, the description thereof is omitted here.
And a fourth sub-step of combining the target tag information and the target data table name information into cache metadata in response to determining that cache metadata corresponding to the target data table name information does not exist in the cache metadata set. Thus, the cached metadata set may be updated.
And a fifth sub-step of adding the cache metadata combined by the target tag information and the target data table name information to the cache metadata set to update the cache metadata set.
And a sixth sub-step of combining the target query data corresponding to the target database data query statement and the target tag information into a target query result.
The resulting individual target query results may then be combined into a set of query results. Thus, a query result set corresponding to each target database data query statement can be obtained.
Second, the query results may be added to the query result set to update the query result set. Thus, remote distributed caches may be updated.
Finally, the updated query result set may be added to the remote distributed cache to update the remote distributed cache. It should be noted that, the query result added to the remote distributed cache may be used as the query result cache information. Thus, the remote distributed cache can be updated, and thus, the hit rate of querying the data in the remote distributed cache can be improved.
The technical scheme is used as an invention point of the embodiment of the disclosure, and solves the second technical problem that when some database query data sentences with higher query frequency are queried through an application program, a cache is not preheated or is preheated only according to text content of the database query sentences, no data corresponding to the database query data sentences with higher query frequency exists in the cache, the application program needs to repeatedly query the data of the database, and then the data is written into the cache. Resulting in a smaller hit rate for the data in the database user query cache. Factors that result in a smaller hit rate for data in the database user query cache are often as follows: when some database query data sentences with higher query frequency are queried through an application program, the cache is not preheated or is preheated only according to the text content of the database query data sentences, no data corresponding to the database query data sentences with higher query frequency are in the cache, and the application program needs to repeatedly query the data of the database and write the data into the cache. If the above factors are solved, the hit rate of the data in the database user query cache can be improved. In order to achieve the effect, when some database query data sentences with higher query frequency are queried, some target database data query sentences with higher query frequency are pulled out, query is performed according to a fixed query flow and interval time, query is performed according to the semantics of the target database data query sentences, and cache metadata and cache are updated. Thereby, warming up of the cache is achieved. Therefore, the hit rate of the data in the database user query cache can be improved.
The above embodiments of the present disclosure have the following advantageous effects: according to the cache data query method of some embodiments of the present disclosure, the hit rate of the database user for querying the data in the cache is improved, the development difficulty of a developer is reduced, the development operation steps are simplified, and the time consumption is shortened. Specifically, the hit rate of the data in the database user query cache is low, the development difficulty of a developer is high, the operation steps are complicated, and the time consumption is long because: the tag information is generated according to the text content of the database data query statement, and the tag information generated according to the database data query statement with the same semantic meaning but different text is possibly inconsistent, so that the tag information generated according to the database data query statement text is more inconsistent with the tag information stored in the cache and generated according to the historical database data query statement text, and the hit rate of the data in the database user query cache is lower; when the application program is added with the function points, the developer needs to develop according to the fixed processing logic again, namely, the developer needs to adapt to the access mode of the database and the cache middleware according to the upper service system, so that the development difficulty of the developer is high, the operation steps are complex, and the time consumption is long. Based on this, the cache data query method of some embodiments of the present disclosure first receives a database data query statement corresponding to a data query request. Thus, a database data query statement may characterize a query statement for querying data. Then, based on the database data query statement, the tag information of the corresponding database data query statement is acquired. Thus, the label information corresponding to the semantics of the database data query statement can be obtained, and the label information can characterize the semantics of the database data query statement. And then, based on the tag information, obtaining a cache result of the corresponding tag information from the associated remote distributed cache. Thereby, cache data corresponding to the tag information can be acquired. Next, it is determined whether the cached data is contained in the cached results. Thus, it can be determined whether or not cache data corresponding to tag information exists in the cache. Then, in response to determining that the cache result does not contain cache data, target data corresponding to the tag information is acquired from the associated database. Thereby, data corresponding to the tag information can be acquired. And finally, sending the target data to the terminal equipment of the database user corresponding to the data query request. Thus, the database user corresponding to the data query request can acquire the data corresponding to the data query request. Also because the tag information is generated from the semantics of the database query data statement, not just from the text content of the database query statement. Thus, when there are two query sentences whose text contents are different but whose semantics are identical, the generated tag information is identical. The label information of the database data query statement can be ensured to be consistent with the label information of the corresponding previous database data query statement in the cache. Therefore, the hit rate of the data in the database user query cache can be improved. And because only the database statement corresponding to the database user request information is required to be sent and the feedback information corresponding to the database statement is received, the number of times that a developer configures the access mode of the database and the cache middleware is reduced, the development difficulty of the developer is reduced, the operation steps are simplified, and the time consumption is shortened. Therefore, the hit rate of the data in the database user query cache is improved, and the development difficulty of a developer is simplified.
With further reference to fig. 2, as an implementation of the method shown in the foregoing figures, the present disclosure provides some embodiments of a method for querying cached data, where the embodiments of the apparatus correspond to those embodiments of the method shown in fig. 1, and the apparatus may be specifically applied to various electronic devices.
As shown in fig. 2, the cache data query device 200 of some embodiments includes: a receiving unit 201, a first acquiring unit 202, a second acquiring unit 203, a determining unit 204, a third acquiring unit 205, and a transmitting unit 206. Wherein the receiving unit 201 is configured to receive a database data query statement corresponding to a data query request; the first obtaining unit 202 is configured to obtain tag information corresponding to the database data query statement based on the database data query statement; the second obtaining unit 203 is configured to obtain a cache result of the corresponding tag information from the associated remote distributed cache based on the tag information; the determining unit 204 is configured to determine whether the cache result contains cache data; the third obtaining unit 205 is configured to obtain, in response to determining that the cache result does not include the cache data, target data corresponding to the tag information from the associated database; the transmitting unit 206 is configured to transmit the target data to the terminal device of the database user corresponding to the data query request.
It will be appreciated that the elements described in the apparatus 200 correspond to the various steps in the method described with reference to fig. 1. Thus, the operations, features and resulting benefits described above for the method are equally applicable to the apparatus 200 and the units contained therein, and are not described in detail herein.
Referring now to fig. 3, a schematic diagram of an electronic device 300 (e.g., a computing device) suitable for use in implementing some embodiments of the present disclosure is shown. The electronic device shown in fig. 3 is merely an example and should not impose any limitations on the functionality and scope of use of embodiments of the present disclosure.
As shown in fig. 3, the electronic device 300 may include a processing means 301 (e.g., a central processing unit, a graphics processor, etc.) that may perform various suitable actions and processes in accordance with a program stored in a Read Only Memory (ROM) 302 or a program loaded from a storage means 308 into a Random Access Memory (RAM) 303. In the RAM 303, various programs and data required for the operation of the electronic apparatus 300 are also stored. The processing device 301, the ROM 302, and the RAM 303 are connected to each other via a bus 304. An input/output (I/O) interface 305 is also connected to bus 304.
In general, the following devices may be connected to the I/O interface 305: input devices 306 including, for example, a touch screen, touchpad, keyboard, mouse, camera, microphone, accelerometer, gyroscope, etc.; an output device 307 including, for example, a Liquid Crystal Display (LCD), a speaker, a vibrator, and the like; storage 308 including, for example, magnetic tape, hard disk, etc.; and communication means 309. The communication means 309 may allow the electronic device 300 to communicate with other devices wirelessly or by wire to exchange data. While fig. 3 shows an electronic device 300 having various means, it is to be understood that not all of the illustrated means are required to be implemented or provided. More or fewer devices may be implemented or provided instead. Each block shown in fig. 3 may represent one device or a plurality of devices as needed.
In particular, according to some embodiments of the present disclosure, the processes described above with reference to flowcharts may be implemented as computer software programs. For example, some embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method shown in the flow chart. In such embodiments, the computer program may be downloaded and installed from a network via communications device 309, or from storage device 308, or from ROM 302. The above-described functions defined in the methods of some embodiments of the present disclosure are performed when the computer program is executed by the processing means 301.
It should be noted that, the computer readable medium described in some embodiments of the present disclosure may be a computer readable signal medium or a computer readable storage medium, or any combination of the two. The computer readable storage medium can be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or a combination of any of the foregoing. More specific examples of the computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In some embodiments of the present disclosure, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In some embodiments of the present disclosure, however, the computer-readable signal medium may comprise a data signal propagated in baseband or as part of a carrier wave, with the computer-readable program code embodied therein. Such a propagated data signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination of the foregoing. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: electrical wires, fiber optic cables, RF (radio frequency), and the like, or any suitable combination of the foregoing.
In some implementations, the clients, servers may communicate using any currently known or future developed network protocol, such as HTTP (HyperText Transfer Protocol ), and may be interconnected with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), the internet (e.g., the internet), and peer-to-peer networks (e.g., ad hoc peer-to-peer networks), as well as any currently known or future developed networks.
The computer readable medium may be contained in the electronic device; or may exist alone without being incorporated into the electronic device. The computer readable medium carries one or more programs which, when executed by the electronic device, cause the electronic device to: receiving a database data query statement corresponding to a data query request; acquiring label information corresponding to the database data query statement based on the database data query statement; based on the tag information, obtaining a cache result of the corresponding tag information from the associated remote distributed cache; determining whether the cache result contains cache data; in response to determining that the cache result does not contain cache data, acquiring target data corresponding to the tag information from the associated database; and sending the target data to the terminal equipment of the database user corresponding to the data query request.
Computer program code for carrying out operations for some embodiments of the present disclosure may be written in one or more programming languages, including an object oriented programming language such as Java, smalltalk, C ++ and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any kind of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or may be connected to an external computer (for example, through the Internet using an Internet service provider).
The flowcharts and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The units described in some embodiments of the present disclosure may be implemented by means of software, or may be implemented by means of hardware. The described units may also be provided in a processor, for example, described as: a processor includes a receiving unit, a first acquiring unit, a second acquiring unit, a determining unit, a third acquiring unit, and a transmitting unit. Where the names of the units do not constitute a limitation on the unit itself in some cases, for example, the receiving unit may also be described as "a unit that receives a database data query statement corresponding to a data query request".
The functions described above herein may be performed, at least in part, by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: a Field Programmable Gate Array (FPGA), an Application Specific Integrated Circuit (ASIC), an Application Specific Standard Product (ASSP), a system on a chip (SOC), a Complex Programmable Logic Device (CPLD), and the like.
The foregoing description is only of the preferred embodiments of the present disclosure and description of the principles of the technology being employed. It will be appreciated by those skilled in the art that the scope of the invention in the embodiments of the present disclosure is not limited to the specific combination of the above technical features, but encompasses other technical features formed by any combination of the above technical features or their equivalents without departing from the spirit of the invention. Such as the above-described features, are mutually substituted with (but not limited to) the features having similar functions disclosed in the embodiments of the present disclosure.

Claims (10)

1. A method of cache data querying, comprising:
receiving a database data query statement corresponding to a data query request;
acquiring label information corresponding to the database data query statement based on the database data query statement;
based on the tag information, obtaining a cache result corresponding to the tag information from an associated remote distributed cache;
determining whether the cache result contains cache data;
in response to determining that the cache result does not contain cache data, acquiring target data corresponding to the tag information from an associated database;
and sending the target data to terminal equipment of a database user corresponding to the data query request.
2. The method of claim 1, wherein prior to the receiving the database data query statement corresponding to the data query request, the method further comprises:
receiving a database data writing statement corresponding to a data writing request;
acquiring tag list information corresponding to the database data writing statement based on the database data writing statement;
deleting each query result cache information corresponding to the tag list information from the associated remote distributed cache to update the associated remote distributed cache, wherein the query result cache information in each query result cache information comprises tag information and query data;
Deleting tag list information corresponding to the database data writing statement in the cache metadata so as to update the cache metadata;
transmitting the database data writing statement to an associated database to update the database;
and sending the updating success information corresponding to the database to the terminal equipment of the database user corresponding to the data writing request.
3. The method of claim 1, wherein the obtaining tag information corresponding to the database data query statement based on the database data query statement comprises:
converting the database data query statement into a physical execution statement;
generating a physical execution tag corresponding to the database data query statement according to the physical execution statement;
and determining the physical execution tag as tag information.
4. The method of claim 3, wherein the obtaining, based on the tag information, a cached result corresponding to the tag information from an associated remote distributed cache comprises:
obtaining cache system link information according to the tag information, wherein the cache system link information comprises cache system links;
And obtaining a caching result corresponding to the tag information according to the caching system link information and the interface information corresponding to the remote distributed cache.
5. The method of claim 1, wherein after the determining whether the cached results contain cached data, the method further comprises:
and responding to the fact that the cache result contains cache data corresponding to the tag information, and sending the cache data to terminal equipment of a database user corresponding to the data query request.
6. The method of claim 1, wherein the obtaining, from the associated database, the target data corresponding to the tag information in response to determining that the cached data is not included in the cached results comprises:
and sending the database data query statement to the database to acquire target data corresponding to the tag information.
7. The method of claim 1, wherein prior to said sending the target data to the terminal device of the database user corresponding to the data query request, the method further comprises:
determining data table name information corresponding to the database data query statement according to the database data query statement;
Determining whether the cache metadata set contains cache metadata corresponding to the data table name information;
and in response to determining that the cache metadata set contains cache metadata corresponding to the data table name information, adding the tag information to the cache metadata corresponding to the data table name information so as to update the cache metadata set.
8. A cache data querying device, comprising:
a receiving unit configured to receive a database data query statement corresponding to a data query request;
a first obtaining unit configured to obtain tag information corresponding to the database data query statement based on the database data query statement;
a second acquisition unit configured to acquire a cache result corresponding to the tag information from an associated remote distributed cache based on the tag information;
a determining unit configured to determine whether the cache result contains cache data;
a third acquisition unit configured to acquire target data corresponding to the tag information from an associated database in response to determining that the cache data is not included in the cache result;
and the sending unit is configured to send the target data to the terminal equipment of the database user corresponding to the data query request.
9. An electronic device, comprising:
one or more processors;
a storage device having one or more programs stored thereon,
when executed by the one or more processors, causes the one or more processors to implement the method of any of claims 1-7.
10. A computer readable medium having stored thereon a computer program, wherein the computer program, when executed by a processor, implements the method of any of claims 1-7.
CN202211698131.2A 2022-12-28 2022-12-28 Cache data query method, device, electronic equipment and computer readable medium Pending CN116226189A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211698131.2A CN116226189A (en) 2022-12-28 2022-12-28 Cache data query method, device, electronic equipment and computer readable medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211698131.2A CN116226189A (en) 2022-12-28 2022-12-28 Cache data query method, device, electronic equipment and computer readable medium

Publications (1)

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

Family

ID=86575881

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211698131.2A Pending CN116226189A (en) 2022-12-28 2022-12-28 Cache data query method, device, electronic equipment and computer readable medium

Country Status (1)

Country Link
CN (1) CN116226189A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117914944A (en) * 2024-03-20 2024-04-19 暗物智能科技(广州)有限公司 Distributed three-level caching method and device based on Internet of things

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117914944A (en) * 2024-03-20 2024-04-19 暗物智能科技(广州)有限公司 Distributed three-level caching method and device based on Internet of things

Similar Documents

Publication Publication Date Title
CN115757400B (en) Data table processing method, device, electronic equipment and computer readable medium
CN111666293A (en) Database access method and device
CN110109983B (en) Method and device for operating Redis database
CN112579928A (en) Page jump method, page jump device, computer equipment and computer readable storage medium
CN113760536A (en) Data caching method and device, electronic equipment and computer readable medium
CN111506475A (en) Data processing method, device and system, readable medium and electronic equipment
CN109697034B (en) Data writing method and device, electronic equipment and storage medium
CN111881216A (en) Data acquisition method and device based on shared template
CN116226189A (en) Cache data query method, device, electronic equipment and computer readable medium
CN111338944A (en) Remote Procedure Call (RPC) interface test method, device, medium and equipment
CN113190517B (en) Data integration method and device, electronic equipment and computer readable medium
CN112836093B (en) Data query method, device, electronic equipment and storage medium
CN111752644A (en) Interface simulation method, device, equipment and storage medium
CN116860286A (en) Page dynamic update method, device, electronic equipment and computer readable medium
US20200348949A1 (en) System and methods for loading objects from hash chains
CN112507676B (en) Method and device for generating energy report, electronic equipment and computer readable medium
CN114785770A (en) Mirror layer file sending method and device, electronic equipment and computer readable medium
CN109669720B (en) Chain type asynchronous request processing method and device based on Promise and electronic equipment
CN112445820A (en) Data conversion method and device
CN111787043A (en) Data request method and device
CN112214500A (en) Data comparison method and device, electronic equipment and storage medium
CN115994151B (en) Data request changing method, device, electronic equipment and computer readable medium
CN112328841B (en) Document processing method and device, electronic equipment and storage medium
CN116467178B (en) Database detection method, apparatus, electronic device and computer readable medium
CN113778909B (en) Method and device for caching data

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