A data query method and device
By building a cache object pool and reusing cache objects, the problem of frequent release and creation of cache objects in the existing technology is solved, and the effect of reducing data cache costs and system overhead and improving data query speed is achieved.
Patent Information
- Application Number
- CN202010832938.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-08-18
- Publication Date
- 2025-02-21
- Estimated Expiration
- 2040-08-18
AI Technical Summary
In the prior art, cache objects are frequently released and created during the update process of data in the cache area, resulting in an increase in data cache cost and system overhead, which reduces the speed of data query.
By building a cache object pool, reuse cache objects to avoid frequent application and release of new cache objects. The specific steps include receiving a data query request, judging whether the target data exists in the cache area. If it does not exist, query it from the database, obtain the cache object in the cache object pool, place the target data in the cache object, and place it in the cache area.
Reduces data caching costs and system overhead and improves data query speed.
Smart Images

Figure CN113760967B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a data query method and device. Background Art
[0002] As the amount of data increases and users' requirements for response speed increase, the application scenarios of non-relational databases (such as key-value storage databases) are also gradually increasing. Non-relational databases build cache areas to cache hot data (data with high query frequency). By updating the data in the cache area, the storage space of the cache area is used to cache hot data to achieve the effect of fast query.
[0003] In the process of implementing the present invention, the inventors found that there are at least the following problems in the prior art:
[0004] During the update process of data in the existing cache area, for the data that needs to be deleted, the cache object corresponding to the data is directly released; then a new cache object is applied for and created from the database system for the newly added data, which increases the data cache cost and system overhead and reduces the data query speed. Summary of the invention
[0005] In view of this, an embodiment of the present invention provides a data query method and device, which realizes the reuse of cache objects by building a cache object pool, thereby reducing data cache costs and system overhead and improving data query speed.
[0006] To achieve the above object, according to a first aspect of an embodiment of the present invention, a data query method is provided, comprising:
[0007] Receive a data query request, and determine whether there is target data corresponding to the data number in the cache object of the cache area according to the data number included in the data query request;
[0008] If it does not exist, query the target data corresponding to the data number from the database;
[0009] Obtain a cache object from the cache object pool, and place target data in the cache object, wherein the cache object has an address space for storing data;
[0010] A cache object including target data is placed in a cache area, and the target data is sent to a sender of a data query request.
[0011] Furthermore, before the step of obtaining the cache object from the cache object pool, it also includes: determining whether there is a cache object in the cache object pool. If not, deleting the data in the cache object in the cache area according to the replacement algorithm, and placing the cache object obtained after the deletion process in the cache object pool.
[0012] Furthermore, it also includes: setting an update cycle, and updating the data in the cache area according to the update cycle and the replacement algorithm.
[0013] Further, the replacement algorithm includes at least one of the following algorithms: a least recently used replacement algorithm, a least used replacement algorithm, and a first-in-first-out replacement algorithm.
[0014] Furthermore, it also includes: the total storage space of the cache object is consistent with the size of the available storage space of the cache area.
[0015] Furthermore, when there is target data corresponding to the data number in the cache object of the cache area, the method further includes: sending the target data to the sender of the data query request, and updating the query status of the target data.
[0016] According to a second aspect of an embodiment of the present invention, there is provided a data query device, comprising:
[0017] The cache area query module is used to receive a data query request and determine whether there is target data corresponding to the data number in the cache object of the cache area according to the data number included in the data query request;
[0018] A database query module, used to query the target data corresponding to the data number from the database when the target data corresponding to the data number does not exist in the cache object of the cache area;
[0019] A cache object acquisition module is used to acquire a cache object from a cache object pool and place target data in the cache object, wherein the cache object has an address space for storing data;
[0020] The data sending module is used to place the cache object including the target data in the cache area, and send the target data to the sender of the data query request.
[0021] Furthermore, it also includes: a judgment module, before the step of obtaining the cache object from the cache object pool, the judgment module is used to: judge whether there is a cache object in the cache object pool, if not, delete the data in the cache object in the cache area according to the replacement algorithm, and place the cache object obtained after the deletion process in the cache object pool.
[0022] According to a third aspect of an embodiment of the present invention, there is provided an electronic device, including:
[0023] one or more processors;
[0024] a storage device for storing one or more programs,
[0025] When one or more programs are executed by one or more processors, the one or more processors implement any of the above-mentioned data query methods.
[0026] According to a fourth aspect of an embodiment of the present invention, a computer-readable medium is provided, on which a computer program is stored, and when the program is executed by a processor, any of the above-mentioned data query methods is implemented.
[0027] An embodiment of the above invention has the following advantages or beneficial effects: because it adopts the method of receiving a data query request, judging whether the target data corresponding to the data number exists in the cache object of the 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 the database; obtaining the cache object from the cache object pool, and placing the target data in the cache object, wherein the cache object has an address space for storing data; placing the cache object including the target data in the cache area, and sending the target data to the sender of the data query request, thereby overcoming the technical problem of increasing data caching cost and system overhead and reducing data query speed due to continuous release and creation of cache objects during the update process of data in the existing cache area, thereby achieving the technical effect of reducing data caching cost and system overhead and improving data query speed.
[0028] The further effects of the above-mentioned non-conventional optional manner will be described below in conjunction with the specific implementation manner. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] The accompanying drawings are used to better understand the present invention and do not constitute an improper limitation of the present invention.
[0030] Figure 1 is a schematic diagram of the main process of the data query method provided according to the first embodiment of the present invention;
[0031] Figure 2 is a schematic diagram of the main process of the data query method provided according to the second embodiment of the present invention;
[0032] Figure 3 is a schematic diagram of main modules of a data query device provided according to an embodiment of the present invention;
[0033] Figure 4 yes Figure 3 A schematic diagram of the main framework of the data query system corresponding to the device;
[0034] Figure 5 is an exemplary system architecture diagram to which embodiments of the present invention may be applied;
[0035] Figure 6It is a schematic diagram of the structure of a computer system of a terminal device or a server suitable for implementing an embodiment of the present invention. DETAILED DESCRIPTION
[0036] The following is a description of exemplary embodiments of the present invention in conjunction with the accompanying drawings, including various details of the embodiments of the present invention to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present invention. Similarly, for clarity and conciseness, the description of well-known functions and structures is omitted in the following description.
[0037] Figure 1 is a schematic diagram of the main process of the data query method provided according to the first embodiment of the present invention; Figure 1 As shown, the data query method provided by the embodiment of the present invention mainly includes:
[0038] Step S101, receiving a data query request, and judging whether there is target data corresponding to the data number in a cache object in a cache area according to the data number included in the data query request.
[0039] Specifically, the data query of the embodiment of the present invention mainly involves non-relational databases, and the cache area is particularly suitable for scenarios such as data query, short connection, news content and product content query. The data number and the data details (target data) are in a one-to-one correspondence. If the data number is key, the corresponding target data is value. For the received data query request, first query whether there is target data corresponding to the data number from the cache area, which is conducive to improving data query efficiency.
[0040] A cache object is one of the storage spaces that the cache area applies for and creates from the database system and is used to store new data in the cache area.
[0041] Step S102: If the target data does not exist, query the database for the target data corresponding to the data number.
[0042] If the target data corresponding to the data number is not found in the cache area, the database is queried according to the data number. The database stores all the data, and the cached data in the cache area is only the hot data in the database (that is, the data with high query frequency).
[0043] Specifically, according to an embodiment of the present invention, after the step of querying the target data corresponding to the data number from the database, the method further includes: determining whether a cache object exists in the cache object pool.
[0044] According to an embodiment of the present invention, in addition to the cache area, a cache object pool including multiple cache objects is also constructed, and the cache object has an address space for storing data. It should be noted that the cache object is only placed in the cache object pool when no data is stored, and the cache object needs to be placed in the cache area after storing data.
[0045] Furthermore, if there is no cache object in the cache object pool, the above-mentioned data query method also includes: deleting the data in the cache object in the cache area according to the replacement algorithm, and placing the cache object obtained after the deletion process in the cache object pool, that is, no data is stored in the address space of the cache object in the cache object pool.
[0046] Through the above settings, when there is no cache object in the cache object pool, that is, if you want to cache data in the cache area at this time, you need to apply for and create a storage space, and use the replacement algorithm to delete the non-hot data in the cache area. That is, after releasing the cache object, there is no need to apply to the database system for creating storage space, and you can directly reuse the cache object that has just been released, thereby achieving the effect of reducing data caching costs and system overhead.
[0047] Preferably, according to an embodiment of the present invention, the replacement algorithm includes at least one of the following algorithms: a least recently used replacement algorithm, a least used replacement algorithm, and a first-in-first-out replacement algorithm.
[0048] From the above description, it can be seen that the purpose of the replacement algorithm in this application is to identify non-hotspot data in the cache area, that is, to determine the query frequency of data in the cache area. It should be noted that the above replacement algorithm is only an example and is not intended to limit the embodiments of the present invention.
[0049] The Least Recently Used (LRU) algorithm considers the most recently used / queried data to be hot data, which is likely to be used again next time, while the data that is rarely used recently is likely not to be used next time.
[0050] The least frequently used replacement algorithm (LFU) considers the data with the lowest usage frequency (query frequency) within a certain period to be non-hotspot data.
[0051] First In First Out (FIFO) replacement algorithm assumes that the probability of the data that is used / queried first not being used again is greater than the probability of the data that has just been used.
[0052] It should be noted that the above replacement algorithm is only an example and is not intended to limit the embodiments of the present invention.
[0053] Step S103, obtaining a cache object from the cache object pool, and placing the target data in the cache object, wherein the cache object has an address space for storing data.
[0054] Through the above settings, an empty cache object (without data stored in it) is directly obtained from the cache object pool, and the target data is placed in it. This realizes the reuse of cache objects, reduces data cache costs and system overhead, and also helps to improve data query speed.
[0055] Specifically, according to an embodiment of the present invention, for the same type of data, multiple fields (or arrays, etc.) in the cache object correspond to corresponding data details respectively, and the process of placing the target data in the cache object can be: according to the data type corresponding to each field in the cache object, the target data is split and written into the corresponding field, thereby completing the data assembly.
[0056] Furthermore, according to an embodiment of the present invention, the data query method further includes: setting an update cycle, and updating the data in the cache area according to the update cycle and the replacement algorithm.
[0057] Through the above settings, the cache area can delete non-hotspot data in it regularly to release cache objects and storage space in the cache area, thereby improving data query efficiency.
[0058] Preferably, according to an embodiment of the present invention, the above data query method further includes: the total storage space of the cache object is consistent with the size of the available storage space of the cache area.
[0059] It should be noted that cache objects are applied for and created by the cache area to the database system. The purpose of building a cache object pool is to place empty cache objects to achieve the reuse of cache objects and reduce data cache costs. Therefore, the total storage space of cache objects indicates the available storage space of the cache area. The current available storage space of the cache area can be determined by whether there are cache objects in the cache object pool or the storage space of the cache objects in it.
[0060] Step S104: placing the cache object including the target data in the cache area, and sending the target data to the sender of the data query request.
[0061] Through the above settings, the target data is more likely to be queried next time, so putting it in the cache area is conducive to improving the data query speed.
[0062] Further, according to an embodiment of the present invention, if target data corresponding to the data number exists in the cache object of the cache area, the above data query method also includes: sending the target data to the sender of the data query request and updating the query status of the target data.
[0063] Through the above settings, the query status of the target data is updated, which helps to determine the query frequency corresponding to the target data and provides a reference for subsequent updating of the data in the cache area.
[0064] According to the technical solution of the embodiment of the present invention, a data query request is received, and according to the data number included in the data query request, it is determined whether there is target data corresponding to the data number in the cache object of the cache area; if not, the target data corresponding to the data number is queried from the database; the cache object is obtained from the cache object pool, and the target data is placed in the cache object, wherein the cache object has an address space for storing data; 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. Therefore, the technical problem of increasing data caching cost and system overhead and reducing data query speed due to continuous release and creation of cache objects in the existing data update process in the cache area is overcome, thereby achieving the technical effect of reducing data caching cost and system overhead and improving data query speed.
[0065] Figure 2 is a schematic diagram of the main process of the data query method provided according to the second embodiment of the present invention; an application scenario of the embodiment of the present invention is the query of merchant information, such as Figure 2 As shown, the data query method provided by the embodiment of the present invention mainly includes:
[0066] Step S201: receiving a data query request, wherein the data query request includes a data number.
[0067] The merchant management system receives data query requests sent by users through the business system. The request includes the merchant ID (ie, data number). In the database of the merchant management system, the merchant ID is the key and the corresponding merchant details (ie, target data) is the value.
[0068] Step S202, determine whether there is target data corresponding to the data number in the cache object of the cache area. If yes, that is, the target data corresponding to the data number exists in the cache area, then execute step S208; if no, that is, the target data corresponding to the data number does not exist in the cache area, then execute step S203.
[0069] The cache area stores data corresponding to popular merchants, while the database stores data corresponding to all merchants. After receiving a data query request, the query is performed first from the cache objects in the cache area, which helps improve query efficiency.
[0070] Step S203, querying the target data corresponding to the data number from the database.
[0071] Step S204, determining whether there is a cache object in the cache object pool, wherein the cache object has an address space for storing data. If yes, that is, there is a cache object in the cache object pool, then executing step S206; if no, that is, there is no cache object in the cache object pool, then going to step S205.
[0072] Specifically, after the target data is queried from the database, the data is sent to the cache area, which helps to directly query the target data in the cache area when the target data is queried later. The above settings are conducive to improving the data query rate.
[0073] Step S205: Deleting the data in the cache object in the cache area according to the replacement algorithm, placing the cache object obtained after the deletion process in the cache object pool, and then executing step S204.
[0074] Through the above settings, when there is no cache object in the cache object pool, that is, if you want to cache data in the cache area at this time, you need to apply for and create a storage space, and use the replacement algorithm to delete the non-hot data in the cache area. That is, after releasing the cache object, there is no need to apply to the database system for creating storage space, and you can directly reuse the cache object that has just been released, thereby achieving the effect of reducing data caching costs and system overhead.
[0075] According to an embodiment of the present invention, the replacement algorithm includes at least one of the following algorithms: a least recently used replacement algorithm, a least used replacement algorithm, and a first-in-first-out replacement algorithm.
[0076] Step S206, obtaining a cache object from the cache object pool, and placing the target data in the cache object.
[0077] Specifically, according to an embodiment of the present invention, no data is stored in the address space of the cache object in the cache object pool. For the same type of data, multiple fields (or arrays, etc.) in the cache object correspond to corresponding data details. The process of placing the target data in the cache object can be: for the data type corresponding to each field in the cache object, the target data is split and written into the corresponding field, that is, the data assembly is completed. For example, the merchant name, merchant address, merchant evaluation, etc. are assembled into different fields of the cache object.
[0078] Preferably, according to an embodiment of the present invention, the above data query method further includes: the total storage space of the cache object is consistent with the size of the available storage space of the cache area.
[0079] It should be noted that the cache object is one of the storage spaces applied for and created by the cache area to the database system. The purpose of building a cache object pool is to place empty cache objects to achieve the reuse of cache objects and reduce data cache costs. At the same time, it can also indicate the available storage space of the cache area. Therefore, the total storage space of the cache object indicates the available storage space of the cache area. The current available storage space of the cache area can be determined by whether there is a cache object in the cache object pool or the storage space of the cache object in it.
[0080] Furthermore, according to an embodiment of the present invention, the data query method further includes: setting an update cycle, and updating the data in the cache area according to the update cycle and the replacement algorithm.
[0081] Through the above settings, the cache area can delete non-hotspot data in it regularly to release cache objects and storage space in the cache area, thereby improving data query efficiency.
[0082] Step S207: placing the cache object including the target data in the cache area, and sending the target data to the sender of the data query request.
[0083] Through the above settings, the target data is more likely to be queried next time, so putting it in the cache area is conducive to improving the data query speed.
[0084] Step S208: Send the target data to the sender of the data query request, and update the query status of the target data.
[0085] Through the above settings, the query status of the target data is updated, which helps to determine the query frequency corresponding to the target data and provides a reference for subsequent updating of the data in the cache area.
[0086] According to the technical solution of the embodiment of the present invention, a data query request is received, and according to the data number included in the data query request, it is determined whether there is target data corresponding to the data number in the cache object of the cache area; if not, the target data corresponding to the data number is queried from the database; the cache object is obtained from the cache object pool, and the target data is placed in the cache object, wherein the cache object has an address space for storing data; 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. Therefore, the technical problem of increasing data caching cost and system overhead and reducing data query speed due to continuous release and creation of cache objects in the existing data update process in the cache area is overcome, thereby achieving the technical effect of reducing data caching cost and system overhead and improving data query speed.
[0087] Figure 3is a schematic diagram of the main modules of the data query device provided according to an embodiment of the present invention; Figure 3 As shown, the data query device 300 provided in the embodiment of the present invention mainly includes:
[0088] The cache area query module 301 is used to receive a data query request and determine whether there is target data corresponding to the data number in the cache object of the cache area according to the data number included in the data query request.
[0089] Specifically, the data query of the embodiment of the present invention mainly involves non-relational databases, and the cache area is particularly suitable for scenarios such as data query, short connection, news content and product content query. The data number and the data details (target data) are in a one-to-one correspondence. If the data number is key, the corresponding target data is value. For the received data query request, first query whether there is target data corresponding to the data number from the cache area, which is conducive to improving data query efficiency.
[0090] A cache object is one of the storage spaces that the cache area applies to the database system for creation and is used to store new data in the cache area.
[0091] The database query module 302 is used to query the target data corresponding to the data number from the database when the target data corresponding to the data number does not exist in the cache object in the cache area.
[0092] If the target data corresponding to the data number is not found in the cache area, the database is queried according to the data number. The database stores the full amount of data, and the cached data in the cache area is only the hot data in the database.
[0093] Specifically, according to an embodiment of the present invention, the data query device 300 further includes a cache object determination module. After the step of querying the target data corresponding to the data number from the database, the cache object determination module is used to: determine whether there is a cache object in the cache object pool.
[0094] According to an embodiment of the present invention, in addition to the cache area, a cache object pool including multiple cache objects is also constructed, and the cache object has an address space for storing data. It should be noted that the cache object is only placed in the cache object pool when no data is stored, and the cache object needs to be placed in the cache area after storing data.
[0095] Furthermore, if there is no cache object in the cache object pool, the cache object determination module is also used to: delete the data in the cache object in the cache area according to the replacement algorithm, and place the cache object obtained after the deletion process in the cache object pool, that is, no data is stored in the address space of the cache object in the cache object pool.
[0096] Through the above settings, when there is no cache object in the cache object pool, that is, if you want to cache data in the cache area at this time, you need to apply for and create a storage space, and use the replacement algorithm to delete the non-hot data in the cache area. That is, after releasing the cache object, there is no need to apply to the database system for creating storage space, and you can directly reuse the cache object that has just been released, thereby achieving the effect of reducing data caching costs and system overhead.
[0097] Preferably, according to an embodiment of the present invention, the replacement algorithm includes at least one of the following algorithms: a least recently used replacement algorithm, a least used replacement algorithm, and a first-in-first-out replacement algorithm.
[0098] From the above description, it can be seen that the purpose of the replacement algorithm in this application is to identify non-hotspot data in the cache area, that is, to determine the query frequency of data in the cache area. It should be noted that the above replacement algorithm is only an example and is not intended to limit the embodiments of the present invention.
[0099] The cache object acquisition module 303 is used to acquire a cache object from the cache object pool and place the target data in the cache object, wherein the cache object has an address space for storing data.
[0100] Through the above settings, an empty cache object (without data stored in it) is directly obtained from the cache object pool, and the target data is placed in it. This realizes the reuse of cache objects, reduces data cache costs and system overhead, and also helps to improve data query speed.
[0101] Furthermore, according to an embodiment of the present invention, the data query device 300 further includes a data updating module, which is used to: set an update cycle, and update the data in the cache area according to the update cycle and a replacement algorithm.
[0102] Through the above settings, the cache area can delete non-hotspot data in it regularly to release cache objects and storage space in the cache area, thereby improving data query efficiency.
[0103] Preferably, according to an embodiment of the present invention, the total storage space of the cache objects is consistent with the size of the available storage space of the cache area.
[0104] It should be noted that cache objects are applied for and created by the cache area to the database system. The purpose of building a cache object pool is to place empty cache objects to achieve the reuse of cache objects and reduce data cache costs. Therefore, the total storage space of cache objects indicates the available storage space of the cache area. The current available storage space of the cache area can be determined by whether there are cache objects in the cache object pool or the storage space of the cache objects in it.
[0105] The data sending module 304 is used to place the cache object including the target data in the cache area, and send the target data to the sender of the data query request.
[0106] Through the above settings, the target data is more likely to be queried next time, so putting it in the cache area is conducive to improving the data query speed.
[0107] Further, according to an embodiment of the present invention, if target data corresponding to the data number exists in the cache object of the cache area, the data sending module 304 is also used to: send the target data to the sender of the data query request and update the query status of the target data.
[0108] Through the above settings, the query status of the target data is updated, which helps to determine the query frequency corresponding to the target data and provides a reference for subsequent updating of the data in the cache area.
[0109] Figure 4 yes Figure 3 A schematic diagram of the main framework of the data query system corresponding to the device; Figure 4 As shown, the business system is the sender of the data query request, the data number in the data query request is the query number (id), and the corresponding target data is the detail data; the JVM (Java Virtual Machine) cache pool is the cache area; the memory object pool is the cache object pool; the data source is the database that stores the full data.
[0110] After receiving the data query request including the query number sent by the business system, the data query system first queries whether there is detailed data (target data) corresponding to the query number in the JVM cache pool. If so, the detailed data is directly sent to the business system; if not, the detailed data corresponding to the query number is queried from the data source, and then a memory object is obtained from the memory object pool to assemble the target data, and the memory object including the target data is placed in the JVM cache pool, and then the target data is sent to the business system. If the memory object does not exist in the memory object pool, a data is deleted from the JVM cache pool according to the LRU algorithm, the released memory object is placed in the memory object pool, and then the operation of assembling the target data is performed, and the memory object including the target data is placed in the JVM cache pool, and then it is sent to the business system.
[0111] According to the technical solution of the embodiment of the present invention, a data query request is received, and according to the data number included in the data query request, it is determined whether there is target data corresponding to the data number in the cache object of the cache area; if not, the target data corresponding to the data number is queried from the database; the cache object is obtained from the cache object pool, and the target data is placed in the cache object, wherein the cache object has an address space for storing data; 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. Therefore, the technical problem of increasing data caching cost and system overhead and reducing data query speed due to continuous release and creation of cache objects in the existing data update process in the cache area is overcome, thereby achieving the technical effect of reducing data caching cost and system overhead and improving data query speed.
[0112] Figure 5 An exemplary system architecture 500 is shown to which the data query method or data query device according to the embodiment of the present invention can be applied.
[0113] like Figure 5 As shown, the system architecture 500 may include terminal devices 501, 502, 503, a network 504 and a server 505 (this architecture is only an example, and the components included in the specific architecture may be adjusted according to the specific application). The network 504 is used to provide a medium for a communication link 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 optical fiber cables, etc.
[0114] Users can use terminal devices 501, 502, 503 to interact with server 505 through network 504 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 501, 502, 503, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social platform software, etc. (only as examples).
[0115] The terminal devices 501 , 502 , and 503 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, desktop computers, and the like.
[0116] The server 505 may be a server that provides various services, such as a backend management server (only an example) that provides support for shopping websites browsed by users using the terminal devices 501, 502, and 503. The backend management server may analyze and process the received data such as the data query request, and feed back the processing result (such as the target data - only an example) to the terminal device.
[0117] 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 .
[0118] It should be understood that Figure 5 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.
[0119] Reference below Figure 6 , which shows a schematic diagram of the structure of a computer system 600 of a terminal device suitable for implementing an embodiment of the present invention. Figure 6 The terminal device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.
[0120] like Figure 6 As shown, 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 part 608 into a random access memory (RAM) 603. In the RAM 603, various programs and data required for the operation of the system 600 are also stored. The CPU 601, the ROM 602, and the RAM 603 are connected to each other via a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.
[0121] The following components are connected to the I / O interface 605: an input section 606 including a keyboard, a mouse, etc.; an output section 607 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 608 including a hard disk, etc.; and a communication section 609 including a network interface card such as a LAN card, a modem, etc. The communication section 609 performs communication processing via a network such as the Internet. A drive 610 is also connected to the I / O interface 605 as needed. A removable medium 611, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 610 as needed, so that a computer program read therefrom is installed into the storage section 608 as needed.
[0122] In particular, according to the embodiments disclosed in the present invention, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present invention include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 609, and / or installed from the removable medium 611. When the computer program is executed by the central processing unit (CPU) 601, the above-mentioned functions defined in the system of the present invention are executed.
[0123] It should be noted that 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 above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present invention, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present invention, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.
[0124] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present invention. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0125] The modules involved in the embodiments of the present invention may be implemented in software or hardware. The modules described may also be set in a processor. For example, they may be described as: a processor includes a cache query module, a database query module, a cache object acquisition module, and a data sending module. The names of these modules do not, in some cases, constitute limitations on the modules themselves. For example, the cache query module may also be described as "a module for receiving a data query request and determining, based on the data number included in the data query request, whether there is target data corresponding to the data number in the cache object of the cache area".
[0126] As another aspect, the present invention also provides a computer-readable medium, which may be included in the device described in the above embodiment; or it may exist independently without being assembled into the device. The above computer-readable medium carries one or more programs, and when the above one or more programs are executed by a device, the device includes: receiving a data query request, judging whether there is a target data corresponding to the data number in the cache object of the 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 the database; obtaining a cache object from the cache object pool, and placing the target data in the cache object, wherein the cache object has an address space for storing data; placing the cache object including the target data in the cache area, and sending the target data to the sender of the data query request.
[0127] According to the technical solution of the embodiment of the present invention, a data query request is received, and according to the data number included in the data query request, it is determined whether there is target data corresponding to the data number in the cache object of the cache area; if not, the target data corresponding to the data number is queried from the database; the cache object is obtained from the cache object pool, and the target data is placed in the cache object, wherein the cache object has an address space for storing data; 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. Therefore, the technical problem of increasing data caching cost and system overhead and reducing data query speed due to continuous release and creation of cache objects in the existing data update process in the cache area is overcome, thereby achieving the technical effect of reducing data caching cost and system overhead and improving data query speed.
[0128] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may occur depending on design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A data query method, characterized in that: include: Receive a data query request, and determine whether there is target data corresponding to the data number in the cache object of the cache area according to the data number included in the data query request; If it does not exist, query the database for the target data corresponding to the data number; Determine whether there is a cache object in the cache object pool, if not, delete the data in the cache object in the cache area according to the replacement algorithm, and place the cache object obtained after the deletion process in the cache object pool; The cache object pool is used to store cache objects that do not store data; Obtaining a cache object from the cache object pool, and placing the target data in the cache object, wherein the cache object has an address space for storing data; A 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.
2. The data query method according to claim 1, characterized in that: Also includes: An update cycle is set, and data in the cache area is updated according to the update cycle and a replacement algorithm.
3. The data query method according to claim 1 or 2, characterized in that: The replacement algorithm includes at least one of the following algorithms: a least recently used replacement algorithm, a least used replacement algorithm, and a first-in-first-out replacement algorithm.
4. The data query method according to claim 1, characterized in that: Also includes: The total storage space of the cache object is consistent with the size of the available storage space of the cache area.
5. The data query method according to claim 1, characterized in that: In the case that the target data corresponding to the data number exists in the cache object of the cache area, the method further includes: sending the target data to the sender of the data query request, and updating the query status of the target data.
6. A data query device, characterized in that: include: The cache area query module is used to receive a data query request and determine whether there is target data corresponding to the data number in the cache object of the cache area according to the data number included in the data query request; a database query module, for querying the target data corresponding to the data number from a database when the target data corresponding to the data number does not exist in the cache object of the cache area; a judgment module, used for judging whether there is a cache object in the cache object pool, and 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 process in the cache object pool; The cache object pool is used to store cache objects that do not store data; A cache object acquisition module, used to acquire a cache object from the cache object pool and place the target data in the cache object, wherein the cache object has an address space for storing data; The data sending module is used to place the cache object including the target data in the cache area, and send the target data to the sender of the data query request.
7. An electronic device, characterized in that: include: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 5.
8. A computer readable medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 5 is implemented.
Citation Information
Patent Citations
Method, device and system for querying order relations
CN101765096A