CN113760967B - A data query method and device - Google Patents
A data query method and device Download PDFInfo
- Publication number
- CN113760967B CN113760967B CN202010832938.5A CN202010832938A CN113760967B CN 113760967 B CN113760967 B CN 113760967B CN 202010832938 A CN202010832938 A CN 202010832938A CN 113760967 B CN113760967 B CN 113760967B
- Authority
- CN
- China
- Prior art keywords
- data
- cache
- cache object
- target 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.)
- Active
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/24—Querying
- G06F16/245—Query processing
- G06F16/2453—Query optimisation
- G06F16/24534—Query rewriting; Transformation
- G06F16/24539—Query rewriting; Transformation using cached or materialised query results
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/24—Querying
- G06F16/245—Query processing
- G06F16/2455—Query execution
-
- Y—GENERAL 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
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02D—CLIMATE 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/00—Energy efficient computing, e.g. low power processors, power management or thermal management
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Computational Linguistics (AREA)
- Data Mining & Analysis (AREA)
- Databases & Information Systems (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
The invention discloses a data query method and a data query device, and relates to the technical field of computers. The method comprises the steps of receiving a data query request, judging whether target data corresponding to a data number exists in a cache object of a cache area according to the data number included in the data query request, querying the target data corresponding to the data number from a database if the target data does not exist, acquiring the cache object from a cache object pool, placing the target data in the cache object, wherein the cache object is provided with an address space for storing the data, placing the cache object comprising the target data in the cache area, and sending the target data to a sender of the data query request. The implementation reduces the data caching cost and the system overhead and improves the data query speed.
Description
Technical Field
The present invention relates to the field of computer technologies, and in particular, to a data query method and apparatus.
Background
Along with the increase of data volume and the increase of the requirement of users on response speed, the application scenes of non-relational databases (such as key-value storage databases) are gradually increased. The non-relational database caches hot spot data (data with high query frequency) by constructing a cache region, and the storage space of the cache region is used for caching the hot spot data by updating the data in the cache region so as to achieve the effect of quick query.
In the process of implementing the present invention, the inventor finds that at least the following problems exist in the prior art:
in the existing updating process of the data in the cache region, the cache object corresponding to the data is directly released for the data to be deleted, and then a new cache object is applied and created from the database system for the newly added data, so that the data caching cost and the system overhead are increased, and the data query speed is reduced.
Disclosure of Invention
In view of the above, embodiments of the present invention provide a data query method and apparatus, which implement reuse of a cache object by constructing a cache object pool, thereby reducing data cache cost and system overhead, and improving data query speed.
To achieve the above object, according to a first aspect of an embodiment of the present invention, there is provided a data query method, including:
receiving a data query request, and judging whether target data corresponding to the data number exists in a cache object of a cache region according to the data number included in the data query request;
If the target data does not exist, inquiring target data corresponding to the data number from a database;
Obtaining a cache object from a cache object pool, and placing target data into the cache object, wherein the cache object is provided with an address space for storing data;
And placing the cache object comprising the target data in the cache area, and sending the target data to a sender of the data query request.
Further, before the step of obtaining the cache object from the cache object pool, the method further comprises the steps of judging whether the cache object exists in the cache object pool, if not, deleting the data in the cache object in the cache area according to a replacement algorithm, and placing the cache object obtained after the deletion in the cache object pool.
Further, the method also comprises the steps of setting an updating period and updating the data in the cache area according to the updating period and a replacement algorithm.
Further, the permutation algorithm includes at least one of a least recently used permutation algorithm, and a first-in first-out permutation algorithm.
Further, the method also comprises the step that the total storage space of the cache object is consistent with the size of the available storage space of the cache region.
Further, when the target data corresponding to the data number exists in the cache object of the cache area, the method further comprises the steps of sending the target data to a sender of the data query request and updating the query state of the target data.
According to a second aspect of an embodiment of the present invention, there is provided a data query apparatus, including:
the cache region query module is used for receiving a data query request and judging whether target data corresponding to the data number exists in a cache object of the cache region according to the data number included in the data query request;
the database query module is used for querying the target data corresponding to the data number from the database under the condition that the target data corresponding to the data number does not exist in the cache object of the cache region;
The cache object acquisition module is used for acquiring a cache object from the cache object pool and placing target data into the cache object, wherein the cache object is provided with an address space for storing data;
And the data sending module is used for placing the cache object comprising the target data in the cache area and sending the target data to a sender of the data query request.
The method further comprises a judging module, wherein the judging module is used for judging whether the cache object exists in the cache object pool or not before the step of acquiring the cache object from the cache object pool, if the cache object does not exist, deleting the data in the cache object in the cache area according to a replacement algorithm, and placing the cache object obtained after the deleting process in the cache object pool.
According to a third aspect of an embodiment of the present invention, there is provided an electronic apparatus including:
one or more processors;
storage means for storing one or more programs,
When the one or more programs are executed by the one or more processors, the one or more processors are caused to implement any of the data query methods described above.
According to a fourth aspect of embodiments of the present invention, there is provided a computer readable medium having stored thereon a computer program which when executed by a processor implements a data querying method as any of the above.
The embodiment of the invention has the advantages that whether the target data corresponding to the data number exists in the cache object of the cache area is judged according to the data number included in the data query request by adopting the technical means of receiving the data query request, if the target data does not exist, the target data corresponding to the data number is queried from the database, the cache object is obtained from the cache object pool and is placed in the cache object, wherein the cache object is provided with an address space for storing the data, the cache object comprising the target data is placed in the cache area, and the target data is sent to a sender of the data query request, so that the technical problems of increasing the data cache cost and the system cost and reducing the data query speed due to the continuous release and creation of the cache object in the existing cache area are overcome, and the technical effects of reducing the data cache cost and the system cost and improving the data query speed are achieved.
Further effects of the above-described non-conventional alternatives are described below in connection with the embodiments.
Drawings
The drawings are included to provide a better understanding of the invention and are not to be construed as unduly limiting the invention. Wherein:
fig. 1 is a schematic diagram of a main flow of a data query method according to a first embodiment of the present invention;
FIG. 2 is a schematic diagram of a main flow of a data query method according to a second embodiment of the present invention;
FIG. 3 is a schematic diagram of main modules of a data query device according to an embodiment of the present invention;
FIG. 4 is a schematic diagram of a main framework of a data query system corresponding to the apparatus shown in FIG. 3;
FIG. 5 is an exemplary system architecture diagram in which embodiments of the present invention may be applied;
fig. 6 is a schematic diagram of a computer system suitable for use in implementing an embodiment of the invention.
Detailed Description
Exemplary embodiments of the present invention will now be described with reference to the accompanying drawings, in which various details of the embodiments of the present invention are included to facilitate understanding, and are to be considered merely exemplary. Accordingly, those of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the invention. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
Fig. 1 is a schematic diagram of a main flow of a data query method according to a first embodiment of the present invention, and as shown in fig. 1, the data query method according to the embodiment of the present invention mainly includes:
Step S101, receiving a data query request, and judging whether target data corresponding to the data number exists in a cache object of the cache area according to the data number included in the data query request.
Specifically, the data query of the embodiment of the invention relates to a main non-relational database, and the cache area is particularly suitable for scenes such as data query, short connection, news content, commodity content query and the like. The data numbers and the data details (target data) are in one-to-one correspondence, and if the data numbers are keys, the corresponding target data are values. For the received data query request, firstly, whether target data corresponding to the data number exists is queried from the buffer area, which is beneficial to improving the data query efficiency.
The cache object is one of storage spaces applied and created by the cache region to the database system and is used for storing newly added data in the cache region.
Step S102, if the target data does not exist, the target data corresponding to the data number is queried from the database.
And under the condition that the target data corresponding to the data number is not queried in the cache region, querying from the database according to the data number. The database stores the whole data, and the cache data in the cache area is only hot spot data (namely, data with high query frequency) in the database.
Specifically, according to the embodiment of the invention, after the step of inquiring the target data corresponding to the data number from the database, the method further comprises the step of determining that a cache object exists in the cache object pool.
According to the embodiment of the invention, a buffer object pool comprising a plurality of buffer objects is also constructed outside the buffer area, and the buffer objects have an address space for storing data. It should be noted that, the cache object is only placed in the cache object pool when the data is not stored, and the data stored in the cache object needs to be placed in the cache region.
Further, if no cache object exists in the cache object pool, the data query method further includes deleting data in the cache object of the cache region according to a replacement algorithm, and placing the cache object obtained after the deleting process in the cache object pool, that is, storing no data in an address space of the cache object in the cache object pool.
Through the arrangement, when no cache object exists in the cache object pool, namely, if data is required to be cached in the cache region, a storage space is required to be applied and created, the replacement algorithm is adopted to delete the non-hot data in the cache region, namely, after the cache object is released, the database system is not required to be applied to create the storage space, and the cache object which is just released is directly reused, so that the effects of reducing the data caching cost and the system overhead are achieved.
Preferably, the permutation algorithm comprises at least one of a least recently used permutation algorithm, and a first-in first-out permutation algorithm, according to an embodiment of the present invention.
From the above description, it is known that the purpose of the replacement algorithm in the present application is to identify non-hot data in the buffer, i.e. determine the query frequency of the data in the buffer. It should be noted that the above permutation algorithm is merely an example, and is not meant to limit the embodiments of the present application.
The last recently Used no permutation algorithm (LRU, least Recently Used) considers the most recently Used/queried data as hot spot data, with a high probability of being Used again next, and the least recently Used data with a high probability of not being Used next.
A least used permutation algorithm (LFU, least Frequently Used) considers the data with the lowest frequency of use (query frequency) over a period of time as non-hotspot data.
A first-in first-Out permutation algorithm (FIFO, first In First Out) that considers the first used/queried data, which has a greater probability of not being reused than the probability of just being used data.
It should be noted that the above permutation algorithm is merely an example, and is not meant to limit the embodiments of the present invention.
Step S103, a cache object is obtained from the cache object pool, and target data is placed in the cache object, wherein the cache object has an address space for storing the data.
Through the arrangement, an empty cache object (in which data is not stored) is directly obtained from the cache object pool, and target data is placed in the empty cache object. The repeated use of the cache object is realized, the data cache cost and the system overhead are reduced, and meanwhile, the data query speed is also improved.
Specifically, according to the embodiment of the invention, for the data of the same type, a plurality of fields (or the form of an array and the like) in the cache object respectively correspond to corresponding data details, and the process of placing the target data in the cache object can be that the target data is split and written into the corresponding fields according to the data types corresponding to the fields in the cache object, namely the data assembly is completed.
Further, according to the embodiment of the invention, the data query method further comprises the steps of setting an update period and updating the data in the cache area according to the update period and a replacement algorithm.
Through the arrangement, the cache region is enabled to delete the non-hot data in the cache region at regular time, so that the cache object is released, the storage space in the cache region is released, and the data query efficiency is improved.
Preferably, according to the embodiment of the present invention, the data query method further includes that the total storage space of the cache object is consistent with the available storage space of the cache region.
It should be noted that, the cache object is applied and created from the cache area to the database system, and the purpose of constructing the cache object pool is to place an empty cache object, so as to realize the reuse of the cache object and reduce the data cache cost. Thus, the total storage space of the cache objects indicates the available storage space of the cache region, and the currently available storage space of the cache region can be determined by whether the cache objects exist in the cache object pool or not or the storage space of the cache objects in the cache object pool.
Step S104, a cache object comprising target data is placed in the cache area, and the target data is sent to a sender of the data query request.
Through the arrangement, the probability that the target data is queried again next time is high, so that the target data is placed in the buffer area, and the data query speed is improved.
Further, according to the embodiment of the invention, if the target data corresponding to the data number exists in the cache object of the cache area, the data query method further comprises the steps of sending the target data to a sender of the data query request and updating the query state of the target data.
Through the arrangement, the query state of the target data is updated, so that the query frequency corresponding to the target data can be determined, and a reference is provided for updating the data in the buffer area subsequently.
According to the technical scheme, the method and the device for updating the data in the cache area comprise the steps of receiving a data query request, judging whether target data corresponding to the data number exists in a cache object of the cache area according to the data number included in the data query request, querying the target data corresponding to the data number from a database if the target data does not exist in the cache object, acquiring the cache object from a cache object pool, and placing the target data in the cache object, wherein the cache object is provided with an address space for storing the data, placing the cache object containing the target data in the cache area, and sending the target data to a sender of the data query request.
Fig. 2 is a schematic diagram of a main flow of a data query method according to a second embodiment of the present invention, where an application scenario of the embodiment of the present invention is a query of merchant information, and as shown in fig. 2, the data query method provided by the embodiment of the present invention mainly includes:
In step S201, a data query request is received, where the data query request includes a data number.
The merchant management system receives a data query request sent by a user through the service system, wherein the request comprises a merchant ID (namely a data number), the merchant ID is a key, and corresponding merchant detail information (namely target data) is a value in a database of the merchant management system.
Step S202, judging whether the buffer object of the buffer area has target data corresponding to the data number. If yes, the step S208 is executed if the target data corresponding to the data number exists in the buffer, and if not, the step S203 is executed if the target data corresponding to the data number does not exist in the buffer.
Data corresponding to the popular merchants are stored in the cache region, data corresponding to all the merchants are stored in the database, and after a data query request is received, query is preferentially performed from the cache objects in the cache region, so that the query efficiency is improved.
Step S203, query the database for the target data corresponding to the data number.
In step S204, it is determined whether a cache object exists in the cache object pool, wherein the cache object has an address space for storing data. If yes, the step S206 is executed if there is a cache object in the cache object pool, otherwise, the step S205 is executed if there is no cache object in the cache object pool.
Specifically, after the target data is queried from the database, the data is sent to the cache region, so that the target data can be directly queried in the cache region when the target data is queried later. Through the arrangement, the data query rate is improved.
Step S205, deleting the data in the cache objects of the cache area according to the replacement algorithm, and placing the cache objects obtained through the deleting process in a cache object pool. Then, step S204 is performed.
Through the arrangement, when no cache object exists in the cache object pool, namely, if data is required to be cached in the cache region, a storage space is required to be applied and created, the replacement algorithm is adopted to delete the non-hot data in the cache region, namely, after the cache object is released, the database system is not required to be applied to create the storage space, and the cache object which is just released is directly reused, so that the effects of reducing the data caching cost and the system overhead are achieved.
According to an embodiment of the invention, the permutation algorithm comprises at least one of a least recently unused permutation algorithm, a least recently used permutation algorithm, and a first-in first-out permutation algorithm.
Step S206, obtaining a cache object from the cache object pool, and placing target data in the cache object.
Specifically, according to the embodiment of the invention, data is not stored in the address space of the cache object in the cache object pool, for the same type of data, a plurality of fields (or arrays and other forms) in the cache object correspond to corresponding data details respectively, and the process of placing the target data in the cache object can be to split the target data according to the data types corresponding to the fields in the cache object and then write the split target data into the corresponding fields, namely completing data assembly. For example, the merchant name, merchant address, merchant rating, etc. are assembled into separate fields of the cache object.
Preferably, according to the embodiment of the present invention, the data query method further includes that the total storage space of the cache object is consistent with the available storage space of the cache region.
It should be noted that, the cache object is one of the storage spaces applied and created by the cache region to the database system, and the purpose of constructing the cache object pool is to place an empty cache object, so as to realize the reuse of the cache object, reduce the data cache cost, and simultaneously indicate the available storage space of the cache region. Thus, the total storage space of the cache objects indicates the available storage space of the cache region, and the currently available storage space of the cache region can be determined by whether the cache objects exist in the cache object pool or not or the storage space of the cache objects in the cache object pool.
Further, according to the embodiment of the invention, the data query method further comprises the steps of setting an update period and updating the data in the cache area according to the update period and a replacement algorithm.
Through the arrangement, the cache region is enabled to delete the non-hot data in the cache region at regular time, so that the cache object is released, the storage space in the cache region is released, and the data query efficiency is improved.
In step S207, the cache object including the target data is placed in the cache area, and the target data is sent to the sender of the data query request.
Through the arrangement, the probability that the target data is queried again next time is high, so that the target data is placed in the buffer area, and the data query speed is improved.
Step S208, the target data is sent to the sending of the data query request, and the query state of the target data is updated.
Through the arrangement, the query state of the target data is updated, so that the query frequency corresponding to the target data can be determined, and a reference is provided for updating the data in the buffer area subsequently.
According to the technical scheme, the method and the device for updating the data in the cache area comprise the steps of receiving a data query request, judging whether target data corresponding to the data number exists in a cache object of the cache area according to the data number included in the data query request, querying the target data corresponding to the data number from a database if the target data does not exist in the cache object, acquiring the cache object from a cache object pool, and placing the target data in the cache object, wherein the cache object is provided with an address space for storing the data, placing the cache object containing the target data in the cache area, and sending the target data to a sender of the data query request.
Fig. 3 is a schematic diagram of main modules of a data query device according to an embodiment of the present invention, and as shown in fig. 3, a data query device 300 according to an embodiment of the present invention mainly includes:
The buffer query module 301 is configured to receive a data query request, and determine whether target data corresponding to a data number exists in a buffer object of the buffer according to the data number included in the data query request.
Specifically, the data query of the embodiment of the invention relates to a main non-relational database, and the cache area is particularly suitable for scenes such as data query, short connection, news content, commodity content query and the like. The data numbers and the data details (target data) are in one-to-one correspondence, and if the data numbers are keys, the corresponding target data are values. For the received data query request, firstly, whether target data corresponding to the data number exists is queried from the buffer area, which is beneficial to improving the data query efficiency.
The buffer memory object is one of the storage spaces created by the buffer memory area applying for the database system, and is used for storing newly added data in the buffer memory area.
The database query module 302 is configured to query the database for the target data corresponding to the data number when the target data corresponding to the data number does not exist in the cache object of the cache area.
And under the condition that the target data corresponding to the data number is not queried in the cache region, querying from the database according to the data number. The database stores the whole data, and the cache data in the cache area is only hot spot data in the database.
Specifically, according to the embodiment of the present invention, the data query device 300 further includes a cache object determining module, after the step of querying the target data corresponding to the data number from the database, for determining that the cache object exists in the cache object pool.
According to the embodiment of the invention, a buffer object pool comprising a plurality of buffer objects is also constructed outside the buffer area, and the buffer objects have an address space for storing data. It should be noted that, the cache object is only placed in the cache object pool when the data is not stored, and the data stored in the cache object needs to be placed in the cache region.
Further, if no cache object exists in the cache object pool, the cache object determining module is further configured to delete data in the cache object of the cache region according to the replacement algorithm, and place the cache object obtained after the deletion in the cache object pool, that is, store no data in an address space of the cache object in the cache object pool.
Through the arrangement, when no cache object exists in the cache object pool, namely, if data is required to be cached in the cache region, a storage space is required to be applied and created, the replacement algorithm is adopted to delete the non-hot data in the cache region, namely, after the cache object is released, the database system is not required to be applied to create the storage space, and the cache object which is just released is directly reused, so that the effects of reducing the data caching cost and the system overhead are achieved.
Preferably, the permutation algorithm comprises at least one of a least recently used permutation algorithm, and a first-in first-out permutation algorithm, according to an embodiment of the present invention.
From the above description, it is known that the purpose of the replacement algorithm in the present application is to identify non-hot data in the buffer, i.e. determine the query frequency of the data in the buffer. It should be noted that the above permutation algorithm is merely an example, and is not meant to limit the embodiments of the present application.
The cache object obtaining module 303 is configured to obtain a cache object from the cache object pool, and place the target data in the cache object, where the cache object has an address space for storing data.
Through the arrangement, an empty cache object (in which data is not stored) is directly obtained from the cache object pool, and target data is placed in the empty cache object. The repeated use of the cache object is realized, the data cache cost and the system overhead are reduced, and meanwhile, the data query speed is also improved.
Further, according to an embodiment of the present invention, the data query device 300 further includes a data update module, configured to set an update period, and update the data in the buffer according to the update period and the replacement algorithm.
Through the arrangement, the cache region is enabled to delete the non-hot data in the cache region at regular time, so that the cache object is released, the storage space in the cache region is released, and the data query efficiency is improved.
Preferably, according to the embodiment of the present invention, the total storage space of the cache object is consistent with the size of the available storage space of the cache region.
It should be noted that, the cache object is applied and created from the cache area to the database system, and the purpose of constructing the cache object pool is to place an empty cache object, so as to realize the reuse of the cache object and reduce the data cache cost. Thus, the total storage space of the cache objects indicates the available storage space of the cache region, and the currently available storage space of the cache region can be determined by whether the cache objects exist in the cache object pool or not or the storage space of the cache objects in the cache object pool.
The data sending module 304 is configured to place a cache object including the target data in the cache area, and send the target data to a sender of the data query request.
Through the arrangement, the probability that the target data is queried again next time is high, so that the target data is placed in the buffer area, and the data query speed is improved.
Further, according to the embodiment of the present invention, if the target data corresponding to the data number exists in the cache object of the cache area, the data sending module 304 is further configured to send the target data to the sender of the data query request, and update the query status of the target data.
Through the arrangement, the query state of the target data is updated, so that the query frequency corresponding to the target data can be determined, and a reference is provided for updating the data in the buffer area subsequently.
Fig. 4 is a schematic diagram of a main frame of a data query system corresponding to the device shown in fig. 3, and as shown in fig. 4, the service system is a sender of a data query request, a data number in the data query request is a query number (id), details (detail) data of target data corresponding to the data query number, a JVM (Java Virtual Machine ) cache pool is a cache area, a memory object pool is a cache object pool, and a data source is a database storing full data.
After the data query system receives a data query request including a query number sent by a service system, firstly querying whether detail data (target data) corresponding to the query number exists in a JVM cache pool, if so, directly sending the detail data to the service system, and if not, querying the detail data corresponding to the query number from a data source, then acquiring a memory object from a memory object pool, assembling the target data, and sending the memory object including the target data to the JVM cache pool. If the memory object pool does not exist, deleting one data from the JVM cache pool according to the LRU algorithm, then executing the operation of assembling the target data in the memory object pool, placing the memory object comprising the target data in the JVM cache pool, and then sending the memory object to the service system.
According to the technical scheme, the method and the device for updating the data in the cache area comprise the steps of receiving a data query request, judging whether target data corresponding to the data number exists in a cache object of the cache area according to the data number included in the data query request, querying the target data corresponding to the data number from a database if the target data does not exist in the cache object, acquiring the cache object from a cache object pool, and placing the target data in the cache object, wherein the cache object is provided with an address space for storing the data, placing the cache object containing the target data in the cache area, and sending the target data to a sender of the data query request.
Fig. 5 illustrates an exemplary system architecture 500 to which the data query method or data query apparatus of embodiments of the present invention may be applied.
As shown in fig. 5, a system architecture 500 may include terminal devices 501, 502, 503, a network 504, and a server 505 (this architecture is merely an example, and the components contained in a particular architecture may be tailored to the application specific case). The network 504 is used as a medium to provide communication links between the terminal devices 501, 502, 503 and the server 505. The network 504 may include various connection types, such as wired, wireless communication links, or fiber optic cables, among others.
A user may interact with the server 505 via the network 504 using the terminal devices 501, 502, 503 to receive or send messages or the like. Various communication client applications may be installed on the terminal devices 501, 502, 503, such as shopping class applications, web browser applications, search class applications, instant messaging tools, mailbox clients, social platform software, etc. (by way of example only).
The terminal devices 501, 502, 503 may be a variety of electronic devices having a display screen and supporting web browsing, including but not limited to smartphones, tablets, laptop and desktop computers, and the like.
The server 505 may be a server providing various services, such as a background management server (by way of example only) providing support for shopping-type websites browsed by users using the terminal devices 501, 502, 503. The background management server may analyze and process the received data such as the data query request, and feed back the processing result (e.g., the target data—only an example) to the terminal device.
It should be noted that, the data query method provided in the embodiment of the present invention is generally executed by the server 505, and accordingly, the data query device is generally disposed in the server 505.
It should be understood that the number of terminal devices, networks and servers in fig. 5 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
Referring now to FIG. 6, there is illustrated a schematic diagram of a computer system 600 suitable for use in implementing an embodiment of the present invention. The terminal device shown in fig. 6 is only an example, and should not impose any limitation on the functions and the scope of use of the embodiment of the present invention.
As shown in fig. 6, the computer system 600 includes a Central Processing Unit (CPU) 601, which can perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM) 602 or a program loaded from a storage section 608 into a Random Access Memory (RAM) 603. In the RAM603, various programs and data required for the operation of the system 600 are also stored. The CPU601, ROM602, and RAM603 are connected to each other through a bus 604. An input/output (I/O) interface 605 is also connected to bus 604.
Connected to the I/O interface 605 are an input section 606 including a keyboard, a mouse, and the like, an output section 607 including a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, a speaker, and the like, a storage section 608 including a hard disk, and the like, and a communication section 609 including a network interface card such as a LAN card, a modem, and the like. The communication section 609 performs communication processing via a network such as the internet. The drive 610 is also connected to the I/O interface 605 as needed. Removable media 611 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is installed as needed on drive 610 so that a computer program read therefrom is installed as needed into storage section 608.
In particular, according to embodiments of the present disclosure, the processes described above with reference to flowcharts may be implemented as computer software programs. For example, 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 an embodiment, the computer program may be downloaded and installed from a network through the communication portion 609, and/or installed from the removable medium 611. The above-described functions defined in the system of the present invention are performed when the computer program is executed by a Central Processing Unit (CPU) 601.
The computer readable medium shown in the present invention 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 a 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 the context of this document, 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 the present invention, however, the computer-readable signal medium may include 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 wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
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 invention. 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 or flowchart illustration, and combinations of blocks in the block diagrams or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The modules involved in the embodiments of the present invention may be implemented in software or in hardware. The described modules may also be provided in a processor, for example, a processor may be described as including a cache area query module, a database query module, a cache object acquisition module, and a data transmission module. The names of the modules do not limit the module itself in some cases, for example, the cache area query module may also be described as "a module for receiving a data query request, and determining, according to a data number included in the data query request, whether target data corresponding to the data number exists in a cache object of a cache area".
As a further aspect, the invention also provides a computer readable medium which may be comprised in the device described in the above embodiments or may be present alone without being fitted into the device. The computer readable medium carries one or more programs, which when executed by the apparatus, cause the apparatus to include receiving a data query request, determining whether target data corresponding to the data number exists in a cache object of a cache area according to the data number included in the data query request, if not, querying the target data corresponding to the data number from a database, acquiring the cache object from a cache object pool, placing the target data in the cache object, wherein the cache object has an address space for storing the data, placing the cache object including the target data in the cache area, and sending the target data to a sender of the data query request.
According to the technical scheme, the method and the device for updating the data in the cache area comprise the steps of receiving a data query request, judging whether target data corresponding to the data number exists in a cache object of the cache area according to the data number included in the data query request, querying the target data corresponding to the data number from a database if the target data does not exist in the cache object, acquiring the cache object from a cache object pool, and placing the target data in the cache object, wherein the cache object is provided with an address space for storing the data, placing the cache object containing the target data in the cache area, and sending the target data to a sender of the data query request.
The above embodiments do not limit the scope of the present invention. It will be apparent to those skilled in the art that various modifications, combinations, sub-combinations and alternatives can occur depending upon design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the scope of the present invention.
Claims (8)
1. A method of querying data, comprising:
receiving a data query request, and judging whether target data corresponding to the data number exists in a cache object of a cache area according to the data number included in the data query request;
If not, inquiring target data corresponding to the data number from a database;
judging whether a cache object exists in a cache object pool, if not, deleting the data in the cache object of the cache area according to a replacement algorithm, and placing the cache object obtained after the deletion in the cache object pool;
obtaining a cache object from the cache object pool, and placing the target data in the cache object, wherein the cache object is provided with an address space for storing data;
and placing the cache object comprising the target data in the cache area, and sending the target data to a sender of the data query request.
2. The data query method of claim 1, further comprising:
setting an update period, and updating the data in the buffer area according to the update period and a replacement algorithm.
3. The data query method of claim 1 or 2, wherein the permutation algorithm comprises at least one of a least recently used permutation algorithm, and a first-in first-out permutation algorithm.
4. The data query method of claim 1, further comprising:
the total storage space of the cache object is consistent with the size of the available storage space of the cache region.
5. The method according to claim 1, further comprising transmitting the target data to a sender of the data query request and updating a query state of the target data in a case where the target data corresponding to the data number exists in a cache object of the cache area.
6. A data query device, comprising:
The cache region query module is used for receiving a data query request and judging whether target data corresponding to the data number exists in a cache object of a cache region according to the data number included in the data query request;
The database query module is used for querying target data corresponding to the data number from a database under the condition that the target data corresponding to the data number does not exist in the cache object of the cache region;
The device comprises a judging module, a buffer storage object pool, a data storage module and a data storage module, wherein the judging module is used for judging whether a buffer storage object exists in the buffer storage object pool, if not, deleting data in the buffer storage object of the buffer storage area according to a replacement algorithm, and placing the buffer storage object obtained after the deleting process in the buffer storage object pool;
the cache object acquisition module is used for acquiring a cache object from the cache object pool and placing the target data in the cache object, wherein the cache object is provided with an address space for storing data;
and the data sending module is used for placing the cache object comprising the target data in the cache area and sending the target data to the sender of the data query request.
7. An electronic device, comprising:
one or more processors;
storage means for storing one or more programs,
When executed by the one or more processors, causes the one or more processors to implement the method of any of claims 1-5.
8. A computer readable medium, on which a computer program is stored, characterized in that the program, when being executed by a processor, implements the method according to any of claims 1-5.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010832938.5A CN113760967B (en) | 2020-08-18 | 2020-08-18 | A data query method and device |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010832938.5A CN113760967B (en) | 2020-08-18 | 2020-08-18 | A data query method and device |
Publications (2)
Publication Number | Publication Date |
---|---|
CN113760967A CN113760967A (en) | 2021-12-07 |
CN113760967B true CN113760967B (en) | 2025-02-21 |
Family
ID=78785597
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202010832938.5A Active CN113760967B (en) | 2020-08-18 | 2020-08-18 | A data query method and device |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN113760967B (en) |
Citations (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101765096A (en) * | 2008-12-26 | 2010-06-30 | 中兴通讯股份有限公司 | Method, device and system for querying order relations |
Family Cites Families (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US6457020B1 (en) * | 2000-03-20 | 2002-09-24 | International Business Machines Corporation | Query optimization using a multi-layered object cache |
CN100485689C (en) * | 2007-01-30 | 2009-05-06 | 浪潮通信信息系统有限公司 | Data speedup query method based on file system caching |
CN101916302B (en) * | 2010-09-01 | 2012-11-21 | 中国地质大学(武汉) | Three-dimensional spatial data adaptive cache management method and system based on Hash table |
CN104850507B (en) * | 2014-02-18 | 2019-03-15 | 腾讯科技(深圳)有限公司 | A kind of data cache method and data buffer storage |
CN104123340B (en) * | 2014-06-25 | 2018-04-20 | 世纪禾光科技发展(北京)有限公司 | A kind of database divides table paging query method and system |
CN109885589B (en) * | 2017-12-06 | 2022-09-16 | 腾讯科技(深圳)有限公司 | Data query method and device, computer equipment and storage medium |
CN110633296A (en) * | 2018-05-31 | 2019-12-31 | 北京京东尚科信息技术有限公司 | Data query method, device, medium and electronic equipment |
-
2020
- 2020-08-18 CN CN202010832938.5A patent/CN113760967B/en active Active
Patent Citations (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101765096A (en) * | 2008-12-26 | 2010-06-30 | 中兴通讯股份有限公司 | Method, device and system for querying order relations |
Also Published As
Publication number | Publication date |
---|---|
CN113760967A (en) | 2021-12-07 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN109657174B (en) | Method and apparatus for updating data | |
CN108984553B (en) | Caching method and device | |
CN113760982B (en) | Data processing method and device | |
CN112445988B (en) | A data loading method and device | |
CN107844488B (en) | Data query method and device | |
CN110648216A (en) | Wind control method and device | |
CN113779082A (en) | Method and device for updating data | |
CN113220981A (en) | Method and device for optimizing cache | |
CN112783887A (en) | Data processing method and device based on data warehouse | |
CN113347052B (en) | Method and device for counting user access data through access log | |
CN112699116B (en) | A data processing method and system | |
CN109213815B (en) | Method, device, server terminal and readable medium for controlling execution times | |
CN113704242A (en) | Data processing method and device | |
CN113239303B (en) | Data storage method and device | |
CN110866002B (en) | Method and device for processing sub-table data | |
CN113760967B (en) | A data query method and device | |
CN113127416A (en) | Data query method and device | |
CN113760965B (en) | Data query method and device | |
CN113722548B (en) | Method and device for processing quotation relation in service system | |
CN117389475A (en) | A data processing method and device | |
CN111698273A (en) | Method and device for processing request | |
CN113138943B (en) | Method and device for processing request | |
CN110019671B (en) | Method and system for processing real-time message | |
CN112711572A (en) | Online capacity expansion method and device suitable for sub-warehouse and sub-meter | |
CN111737218A (en) | File sharing method and device |
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 | ||
GR01 | Patent grant | ||
GR01 | Patent grant |