WO2021164487A1 - 一种数据的查询方法和装置 - Google Patents

一种数据的查询方法和装置 Download PDF

Info

Publication number
WO2021164487A1
WO2021164487A1 PCT/CN2021/072678 CN2021072678W WO2021164487A1 WO 2021164487 A1 WO2021164487 A1 WO 2021164487A1 CN 2021072678 W CN2021072678 W CN 2021072678W WO 2021164487 A1 WO2021164487 A1 WO 2021164487A1
Authority
WO
WIPO (PCT)
Prior art keywords
data
module
cache
storage system
target
Prior art date
Application number
PCT/CN2021/072678
Other languages
English (en)
French (fr)
Inventor
吴武桓
孙国建
杨艳艳
Original Assignee
京东数字科技控股股份有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 京东数字科技控股股份有限公司 filed Critical 京东数字科技控股股份有限公司
Publication of WO2021164487A1 publication Critical patent/WO2021164487A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/245Query processing
    • G06F16/2453Query optimisation
    • G06F16/24534Query rewriting; Transformation
    • G06F16/24539Query rewriting; Transformation using cached or materialised query results
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/245Query processing
    • G06F16/2455Query execution
    • G06F16/24552Database cache management

Definitions

  • the present disclosure relates to the computer field, and in particular to a data query method and device.
  • the commodity system of e-commerce provides a query service interface, and the single cache used by it has certain defects.
  • the current processing method is to store the full amount of data in the database in the local memory of the machine. All query services are queried in the local memory of the machine. If the data exists in the memory, it will return the queried data, and if it does not exist, it will return directly. mistake.
  • the present disclosure provides a data query method and device to at least solve the technical problem of low data query efficiency in related technologies.
  • a data query method including:
  • the storage system includes: the memory module, a cache module and a database module, the cache module is configured to cache the data stored in the database module, The memory module is configured to store data with preset data characteristics among the data cached by the cache module;
  • the target data stored in the memory module is sent.
  • the method further includes:
  • the target data stored in the cache module is sent.
  • the method further includes:
  • the target data is queried from the cache module of the storage system, determining whether the target data has the preset data characteristics
  • the target data is stored in the memory module.
  • the method further includes:
  • the target data is not queried from the cache module of the storage system, query the target data from the database module of the storage system;
  • the target data stored in the database module is stored in the cache module.
  • the method before receiving the data query request sent by the client, the method further includes:
  • the cache module and the database module Store the application data in the cache module and the database module, and determine that the preset data characteristics include: the data access frequency is higher than the target frequency, or the data volume is lower than the target data volume.
  • the Methods after storing the application data in the cache module and the database module, and storing the data with the preset data characteristics in the application data in the memory module, the Methods also include:
  • the Methods after storing the application data in the cache module and the database module, and storing the data with the preset data characteristics in the application data in the memory module, the Methods also include:
  • a data query device including:
  • the first receiving module is configured to receive a data query request, wherein the data query request is used to request to query target data in the storage system;
  • the first query module is configured to query the target data from the memory module of the storage system, wherein the storage system includes: the memory module, a cache module, and a database module, and the cache module is configured to cache the Data stored in the database module, the memory module is configured to store data with preset data characteristics among the data cached by the cache module;
  • the first sending module is configured to send the target data stored in the memory module when the target data is queried from the memory module of the storage system.
  • a storage medium includes a stored program, and the above-mentioned method is executed when the program runs.
  • an electronic device including a memory, a processor, and a computer program stored on the memory and capable of running on the processor, and the processor executes the above-mentioned method through the computer program.
  • a data query request is received, where the data query request is used to request to query the target data in the storage system; the target data is queried from the memory module of the storage system, where the storage system includes: a memory module, a cache Module and database module, the cache module is set to cache the data stored in the database module, and the memory module is set to store data with preset data characteristics among the data cached by the cache module; when the target data is queried from the memory module of the storage system Next, the method of sending the target data stored in the memory module.
  • the storage system includes: a memory module, a cache module and a database module.
  • the cache module is set to cache the data stored in the database module, and the memory module is set to store Preset data characteristics, so that the data in the database module is stored in the cache module and the memory module through the secondary cache mechanism.
  • the memory module will be queried first. If the target data has preset data Characteristic, then the target data may be hit in the memory module. If it is hit, the target data stored in the memory module will be returned.
  • the secondary cache mechanism Through the above-mentioned secondary cache mechanism, the goal of quickly hitting the data is achieved, thereby improving the data
  • the technical effect of query efficiency further solves the technical problem of low data query efficiency in related technologies.
  • Fig. 1 is a schematic diagram of a hardware environment of a data query method according to an embodiment of the present disclosure
  • Fig. 2 is a flowchart of an optional data query method according to an embodiment of the present disclosure
  • FIG. 3 is a schematic diagram of a comparison of storage architectures of various storage systems according to an embodiment of the present disclosure
  • FIG. 4 is a schematic diagram of a flow of second-level caching hotspot data according to an optional embodiment of the present disclosure
  • Fig. 5 is a schematic diagram of an optional data query device according to an embodiment of the present disclosure.
  • Fig. 6 is a structural block diagram of a terminal according to an embodiment of the present disclosure.
  • an embodiment of a method for querying data is provided.
  • the above-mentioned data query method can be applied to the hardware environment formed by the terminal 101 and the server 103 as shown in FIG. 1.
  • the server 103 is connected to the terminal 101 through the network, and can be used to provide services (such as game services, application services, etc.) for the terminal or the client installed on the terminal.
  • the database can be set on the server or independently of the server. It is used to provide data storage services for the server 103.
  • the aforementioned networks include, but are not limited to: wide area networks, metropolitan area networks, or local area networks.
  • the terminal 101 is not limited to PCs, mobile phones, tablet computers, and the like.
  • the data query method in the embodiment of the present disclosure may be executed by the server 103, may also be executed by the terminal 101, or may be executed jointly by the server 103 and the terminal 101.
  • the terminal 101 executing the data query method of the embodiment of the present disclosure may also be executed by a client installed on it.
  • Fig. 2 is a flowchart of an optional data query method according to an embodiment of the present disclosure. As shown in Fig. 2, the method may include the following steps:
  • Step S202 Receive a data query request, where the data query request is used to request to query target data in the storage system;
  • Step S204 Query the target data from the memory module of the storage system, where the storage system includes: the memory module, a cache module, and a database module, the cache module is configured to cache the data stored in the database module Data, the memory module is configured to store data with preset data characteristics among the data cached by the cache module;
  • Step S206 If the target data is queried from the memory module of the storage system, send the target data stored in the memory module.
  • the storage system includes: a memory module, a cache module, and a database module.
  • the cache module is set to cache data stored in the database module
  • the memory module is set to store data that has preset data characteristics among the data cached by the cache module.
  • the data in the database module is stored in the cache module and the memory module through the secondary cache mechanism.
  • the memory module is first queried. If the target data has preset data characteristics, then The memory module may hit the target data, if it hits, the target data stored in the memory module will be returned.
  • the goal of quickly hitting the data is achieved, thereby achieving the technical effect of improving the efficiency of data query , Thereby solving the technical problem of low data query efficiency in related technologies.
  • the data query request can be, but not limited to, sent by the client, or sent by the server.
  • the client can be, but not limited to, clients that include various functional applications, such as online education applications. , Instant messaging applications, community space applications, game applications, shopping applications, browser applications, financial applications, multimedia applications, live broadcast applications, etc.
  • the data query request is used to request to query target data in the storage system.
  • the target data may include, but is not limited to, product information, audio and video files, chat records, transaction information, and so on.
  • the storage system includes: a memory module, a cache module and a database module, the cache module is set to cache data stored in the database module, and the memory module is set to store data cached by the cache module with preset data characteristics The data.
  • the cache module caches the full amount of data in the database, and stores the data with preset data characteristics among the data cached by the cache module in the memory module.
  • the memory module first stores the preset data characteristics in the memory module Query in the data, if it hits, it can be returned directly.
  • the preset data characteristics can be, but are not limited to, used to represent the attribute characteristics of the data, such as the amount of data, the frequency of data access, the sensitivity of the data, and so on.
  • step S206 if the target data is hit in the memory module, it can be returned directly.
  • FIG. 3 is a schematic diagram of a comparison of the storage architectures of various storage systems according to an embodiment of the present disclosure.
  • the storage system (a The architecture of) only uses DB (database module).
  • the disadvantage of this scheme is that the pressure on the DB will be great and the performance will be poor.
  • the architecture of the storage system (b) uses a memory module (cacha) and a database module (DB). Its disadvantage is the high memory pressure and the strong dependence on ZK.
  • storage system (a) and storage system (b) are used for data storage, and data query efficiency is relatively low.
  • the architecture of the storage system (c) is provided.
  • the architecture of the storage system is separated from reading and writing.
  • the reading and writing of a single-application product is split into two applications, reading and writing, and synchronization between It uses ZK (a web application development framework) to do zookeeper (zookeeper coordination service) and timing tasks (QUARTZ) to ensure synchronization.
  • ZK a web application development framework
  • zookeeper zookeeper coordination service
  • QUARTZ timing tasks
  • the write application database module (DB)
  • the read application memory module + cache module ( Cache+R2M)
  • the DB service handles the read and write operations of the management background (console) and the read request of the cache+R2M application (that is, the internal read and write request of the system), and the cache+R2M service uniformly handles the read request of the external application (web)
  • the read in this read-write separation mainly refers to read requests from external applications.
  • the method further includes:
  • the query is performed from the cache module, and if the target data is found in the cache module, the target data stored in the cache module is returned.
  • the method further includes:
  • the target data is found in the cache module, it is determined whether the target data is suitable for storage in the memory, that is, whether the target data has preset data characteristics. If the target data has preset data characteristics, it is added to the memory, and then the target data can be directly hit in the memory in subsequent queries, which improves the efficiency of the query.
  • the method further includes:
  • the database is searched, and the target data found in the database is cached in the cache module.
  • the method before receiving the data query request sent by the client, the method further includes:
  • S3. Store the application data in the cache module and the database module, and determine that the preset data characteristics include: the data access frequency is higher than the target frequency, or the data volume is lower than the target data volume.
  • the memory module can be, but not limited to, set to store hotspot data, and the cache module stores the full amount of data.
  • Hotspot data can be but not limited to: frequent access (such as products, responsibilities, terms), non-large-capacity fields (such as national area code tables, tariff tables, etc.) Is a large-capacity field).
  • a cache block will be set for the business table. If the business table is hot data, the second-level cache processing (memory + cache) is performed, and the non-hot data is only cached at the first level (that is, only the cache is used, and the memory is not used. ) Processing to save memory space.
  • the judgment of the hot data here may not be a dynamic judgment of the system, but set in advance during development.
  • the second-level cache can improve the high concurrency and high availability of services, the hotspot cache can improve the memory utilization, and give priority to ensuring the efficient concurrency of hot data .
  • the application data is stored in the cache module and the database module, and the data with the preset data characteristics in the application data is stored in the memory module After the middle, it also includes:
  • the cache module and the database are updated synchronously, and the memory is cleared.
  • the query is performed in the cache module and the data with preset data characteristics is stored in the memory module, thereby ensuring data consistency and realizing data Sync updates.
  • a real-time data synchronization process is provided.
  • the write application (base) passes through the Zookeeper distributed service middleware.
  • the broadcast notification mechanism writes update nodes (such as products) into the ZK configuration, informs each instance of the read application (cache) to monitor broadcast notifications, and deletes the memory data (such as products) under each instance according to the notification node to ensure strong data consistency.
  • the application data is stored in the cache module and the database module, and the data with the preset data characteristics in the application data is stored in the memory module After the middle, it also includes:
  • S1 Check every target time interval whether the first data identifier of the data stored in the memory module is consistent with the second data identifier of the data stored in the cache module;
  • the target time interval may be preset, or may be dynamically adjusted according to historical processing information of the data.
  • the data identifiers of the data stored in the memory and the cache are queried every target time interval to see if they are consistent, and the inconsistencies are processed to ensure the consistency of the data and realize the determination of the data. Synchronize.
  • the above-mentioned data identifier is used to uniquely identify the version of the data, and the version number can be used as the above-mentioned data identifier, but is not limited to.
  • a data timing synchronization process is provided, and every half an hour (time can be customized) is polled to read the data version stored in the memory of each cache block of the application (cache) and the data stored in the cache (R2M) Whether the versions are consistent or not, the memory data is considered to be old data that has not been updated, and the memory data is deleted.
  • Timing synchronization can prevent data inconsistency caused by abnormal ZK synchronization or other reasons, thereby ensuring data consistency within a certain time range.
  • FIG. 4 is a flow chart of a second-level cache hotspot data according to an optional embodiment of the present disclosure.
  • the schematic diagram, as shown in Figure 4, can be seen when product query, the query order can be memory module (for example, use cache to store hot data [hot]), cache module (for example, you can use Redis, that is, R2M), database module (for example, Use MongoDB (a database based on distributed file storage), which can be backed up through MySQL (a relational database management system), and refresh the cache module (R2M) when the product is updated (UPDATE), and then delete it at the same time ( DEL) the data in the memory module (cache), and through the version check task, regularly check whether the data in the cache module and the memory module are consistent. If they are inconsistent, clear the memory module to ensure data consistency. When the data is updated, it will ensure that the updated data is flashed to the cache module, but the memory module is notified
  • the process of the above-mentioned secondary cache mechanism is: memory-cache-DB.
  • the cache module and the memory module are referenced at the same time to create a second-level hot data cache.
  • the query plan for the second-level cache can be: store part of the hot data in the memory module and store all the data in the cache. Module, then DB database module as an alternate query method.
  • the order of query is to first check the memory module. If the memory module has the data to be queried, it will return directly. If it does not exist, it will check the cache module. If it is hot data, it will be checked after the cache module.
  • the query can be achieved level by level, and the query volume of each level will show an order of magnitude decrease, because most of the queries can be hit by the memory module, the query success rate of the memory module will be very high, and then part of the big data In other words, data with a small amount of data request is placed in the cache module for query.
  • the above process also provides a data update mechanism and a disaster recovery mechanism.
  • the data update concurrently updates the database module and the cache module, and then asynchronous broadcast deletes the data of the memory module to ensure data consistency.
  • asynchronous broadcast deletes the data of the memory module to ensure data consistency.
  • start the regular version check task and cache the version numbers of the hot data at the same time to prevent the inconsistency of the second-level cache data due to broadcast notifications, etc., and allow the data to be inconsistent within a certain period of time, but the final data is consistent.
  • the ability of high concurrency and high availability of services can be improved, and the efficiency of memory usage can be improved.
  • the memory usage rate has reached 50%, and may even reach 80%.
  • the memory usage rate after the caching mechanism provided by this optional embodiment reaches below 30%.
  • the second-level hotspot cache solution is adopted to enhance the service concurrency while improving the memory utilization rate.
  • a disaster recovery mechanism is added on the basis of the second-level cache to ensure the final consistency of the data.
  • the method according to the above embodiment can be implemented by means of software plus the necessary general hardware platform, of course, it can also be implemented by hardware, but in many cases the former is Better implementation.
  • the technical solution of the present disclosure essentially or the part that contributes to the existing technology can be embodied in the form of a software product, and the computer software product is stored in a storage medium (such as ROM/RAM, magnetic disk, The optical disc) includes several instructions to make a terminal device (which can be a mobile phone, a computer, a server, or a network device, etc.) execute the methods described in the various embodiments of the present disclosure.
  • Fig. 5 is a schematic diagram of an optional data query device according to an embodiment of the present disclosure. As shown in Fig. 5, the device may include:
  • the first receiving module 52 is configured to receive a data query request, wherein the data query request is used to request to query target data in the storage system;
  • the first query module 54 is configured to query the target data from the memory module of the storage system, wherein the storage system includes: the memory module, a cache module, and a database module, the cache module is set as a cache The data stored in the database module, and the memory module is configured to store data with preset data characteristics among the data cached by the cache module;
  • the first sending module 56 is configured to send the target data stored in the memory module when the target data is queried from the memory module of the storage system.
  • first receiving module 52 in this embodiment can be configured to perform step S202 in the embodiment of the present disclosure
  • first query module 54 in this embodiment can be configured to perform step S204 in the embodiment of the present disclosure
  • the first sending module 56 in this embodiment may be configured to execute step S206 in the embodiment of the present disclosure.
  • the storage system includes: a memory module, a cache module and a database module.
  • the cache module is set to cache data stored in the database module
  • the memory module is set to store data with preset data characteristics among the data cached by the cache module.
  • the data in the database module is stored in the cache module and the memory module through the secondary cache mechanism.
  • the memory module is first queried. If the target data has preset data characteristics, then the memory module is It may hit the target data. If it hits, the target data stored in the memory module will be returned.
  • the secondary cache mechanism the goal of quickly hitting the data is achieved, thereby achieving the technical effect of improving the efficiency of data query, and then solving The technical problem of low data query efficiency in related technologies.
  • the device further includes:
  • the second query module is configured to, after querying the target data from the memory module of the storage system, if the target data is not queried from the memory module of the storage system, from the storage system
  • the second sending module is configured to send the target data stored in the cache module when the target data is queried from the cache module of the storage system.
  • the device further includes:
  • the determining module is configured to determine whether the target data has the target data after the target data is queried from the cache module of the storage system after the target data is queried from the cache module of the storage system. Preset data characteristics;
  • the first storage module is configured to store the target data in the memory module when it is determined that the target data has the preset data characteristics.
  • the device further includes:
  • the third query module is configured to, after querying the target data from the cache module of the storage system, if the target data is not queried from the cache module of the storage system, from the storage system
  • the database module queries the target data
  • a third sending module configured to send the target data stored in the database module to the client when the target data is queried from the database module of the storage system;
  • the second storage module is configured to store the target data stored in the database module in the cache module.
  • the device further includes:
  • An establishment module configured to establish the memory module, the cache module, and the database module in the storage system before receiving the data query request sent by the client;
  • An obtaining module configured to obtain application data of the target application corresponding to the client
  • the third storage module is configured to store the application data in the cache module and the database module, and determine that the preset data characteristics include: the frequency of data access is higher than the target frequency, or the amount of data is lower than the target The amount of data.
  • the device further includes:
  • the second receiving module is configured to store the application data in the cache module and the database module, and store the data with the preset data characteristics in the application data in the memory module , Receiving data update information sent by the target application;
  • the update module is configured to update the data stored in the cache module and the database module according to the instructions of the data update information, and delete the data stored in the memory module.
  • the device further includes:
  • the checking module is configured to store the application data in the cache module and the database module, and store the data with the preset data characteristics in the application data in the memory module, each time Checking at target time intervals whether the first data identifier of the data stored in the memory module is consistent with the second data identifier of the data stored in the cache module;
  • the deleting module is configured to delete the data stored in the memory module when it is checked that the first data identifier is inconsistent with the second data identifier.
  • the above-mentioned modules can run in the hardware environment as shown in FIG. 1, and can be implemented by software or hardware, where the hardware environment includes a network environment.
  • a server or terminal for implementing the above-mentioned data query method.
  • FIG. 6 is a structural block diagram of a terminal according to an embodiment of the present disclosure.
  • the terminal may include: one or more (only one is shown in the figure) processor 601, memory 603, and transmission device 605
  • the terminal may also include an input and output device 607.
  • the memory 603 can be configured to store software programs and modules, such as the program instructions/modules corresponding to the data query method and device in the embodiments of the present disclosure.
  • the processor 601 runs the software programs and modules stored in the memory 603, thereby Perform various functional applications and data processing, that is, realize the above-mentioned data query method.
  • the memory 603 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory.
  • the memory 603 may further include a memory remotely provided with respect to the processor 601, and these remote memories may be connected to the terminal through a network. Examples of the aforementioned networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.
  • the aforementioned transmission device 605 is configured to receive or send data via a network, and may also be configured to transmit data between the processor and the memory.
  • the above-mentioned optional examples of networks may include wired networks and wireless networks.
  • the transmission device 605 includes a network adapter (Network Interface Controller, NIC), which can be connected to other network devices and routers via a network cable so as to communicate with the Internet or a local area network.
  • the transmission device 605 is a radio frequency (RF) module, which is configured to communicate with the Internet in a wireless manner.
  • RF radio frequency
  • the memory 603 is configured to store an application program.
  • the processor 601 may call the application program stored in the memory 603 through the transmission device 605 to perform the following steps:
  • the storage system includes: the memory module, a cache module, and a database module, and the cache module is configured to cache data stored in the database module.
  • the memory module is configured to store data with preset data characteristics among the data cached by the cache module;
  • the storage system includes: a memory module, a cache module and a database module.
  • the cache module is set to cache data stored in the database module, and the memory module is set to store data with preset data characteristics among the data cached by the cache module.
  • the data is stored in the cache module and the memory module through the mechanism of the secondary cache.
  • the memory module is first queried. If the target data has preset data characteristics, then the memory module may hit the target If the data is hit, it returns to the target data stored in the memory module.
  • the goal of quickly hitting the data is achieved, thereby achieving the technical effect of improving the efficiency of data query, and then solving the data in related technologies. Query technical issues with low efficiency.
  • the structure shown in Figure 6 is only for illustration, and the terminal can be a smart phone (such as an Android phone, an iOS phone, etc.), a tablet computer, a handheld computer, and a mobile Internet device (MID), Terminal equipment such as PAD.
  • FIG. 6 does not limit the structure of the above-mentioned electronic device.
  • the terminal may also include more or fewer components (such as a network interface, a display device, etc.) than those shown in FIG. 6, or have a configuration different from that shown in FIG. 6.
  • the program can be stored in a computer-readable storage medium, which can be Including: flash disk, read-only memory (Read-Only Memory, ROM), random access device (Random Access Memory, RAM), magnetic disk or optical disk, etc.
  • the embodiment of the present disclosure also provides a storage medium.
  • the above-mentioned storage medium may be used to execute the program code of the data query method.
  • the foregoing storage medium may be located on at least one of the multiple network devices in the network shown in the foregoing embodiment.
  • the storage medium is configured to store program code for executing the following steps:
  • the storage system includes: the memory module, a cache module, and a database module, and the cache module is configured to cache data stored in the database module.
  • the memory module is configured to store data with preset data characteristics among the data cached by the cache module;
  • the foregoing storage medium may include, but is not limited to: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, magnetic disk Various media that can store program codes, such as discs or optical discs.
  • the integrated unit in the foregoing embodiment is implemented in the form of a software functional unit and sold or used as an independent product, it may be stored in the foregoing computer-readable storage medium.
  • the technical solution of the present disclosure essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, A number of instructions are included to enable one or more computer devices (which may be personal computers, servers, or network devices, etc.) to perform all or part of the steps of the methods described in the various embodiments of the present disclosure.
  • the disclosed client can be implemented in other ways.
  • the device embodiments described above are only illustrative.
  • the division of the units is only a logical function division.
  • there may be other division methods for example, multiple units or components may be combined or may be Integrate into another system, or some features can be ignored or not implemented.
  • the displayed or discussed mutual coupling or direct coupling or communication connection may be indirect coupling or communication connection through some interfaces, units or modules, and may be in electrical or other forms.
  • the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the objectives of the solutions of the embodiments.
  • the functional units in the various embodiments of the present disclosure may be integrated into one processing unit, or each unit may exist alone physically, or two or more units may be integrated into one unit.
  • the above-mentioned integrated unit can be implemented in the form of hardware or software functional unit.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Computational Linguistics (AREA)
  • Data Mining & Analysis (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
  • Information Transfer Between Computers (AREA)
  • Memory System Of A Hierarchy Structure (AREA)

Abstract

一种数据的查询方法和装置,其中,该方法包括:接收数据查询请求,其中,数据查询请求用于请求查询存储系统中的目标数据(S202);从存储系统的内存模块中查询目标数据,其中,存储系统包括:内存模块,缓存模块和数据库模块,缓存模块设置为缓存数据库模块中存储的数据,内存模块设置为存储缓存模块缓存的数据中具有预设数据特征的数据(S204);在从存储系统的内存模块中查询到目标数据的情况下,发送内存模块中存储的目标数据(S206)。该方法解决了数据查询效率较低的技术问题。

Description

一种数据的查询方法和装置
本公开要求于2020年02月20日提交中国专利局、优先权号为202010105429.2、发明名称为“一种数据的查询方法和装置”的中国专利申请的优先权,其全部内容通过引用结合在本公开中。
技术领域
本公开涉及计算机领域,尤其涉及一种数据的查询方法和装置。
背景技术
电子商务的商品系统提供查询服务接口,其使用的单一缓存均存在一定缺陷。
目前的处理方式是将数据库中的全量数据保存在机器本地的内存中,所有的查询服务都是在机器本地的内存中进行查询,如果内存中存在就返回查询到的数据,不存在就直接返回错误。
在实现本发明过程中,发明人发现这个方案的缺陷是内存占用率很高,尤其是随着时间的推移,数据逐步增多,会导致需要不断增加内存才能满足。每一次的数据查询均需要在全量数据中进行操作,随着数据量的增加,数据的查询效率会越来越低。
针对上述的问题,目前尚未提出有效的解决方案。
发明内容
本公开提供了一种数据的查询方法和装置,以至少解决相关技术中数据查询效率较低的技术问题。
根据本公开实施例的一个方面,提供了一种数据的查询方法,包括:
接收数据查询请求,其中,所述数据查询请求用于请求查询存储系统中的目标数据;
从所述存储系统的内存模块中查询所述目标数据,其中,所述存储系统包括:所述内存模块,缓存模块和数据库模块,所述缓存模块设置为缓存所述数据库模块中存储的数据,所述内存模块设置为存储所述缓存模块缓存的数据中具有预设数据特征的数据;
在从所述存储系统的内存模块中查询到所述目标数据的情况下,发送所述内存模块中存储的所述目标数据。
可选地,在从所述存储系统的内存模块中查询所述目标数据之后,所述方法还包括:
在从所述存储系统的内存模块中未查询到所述目标数据的情况下,从所述存储系统的缓存模块查询所述目标数据;
在从所述存储系统的缓存模块中查询到所述目标数据的情况下,发送所述缓存模块中存储的所述目标数据。
可选地,在从所述存储系统的缓存模块查询所述目标数据之后,所述方法还包括:
在从所述存储系统的缓存模块中查询到所述目标数据的情况下,确定所述目标数据是否具有所述预设数据特征;
在确定所述目标数据具有所述预设数据特征的情况下,将所述目标数据存储到所述内存模块中。
可选地,在从所述存储系统的缓存模块查询所述目标数据之后,所述方法还包括:
在从所述存储系统的缓存模块中未查询到所述目标数据的情况下,从所述存储系统的数据库模块查询所述目标数据;
在从所述存储系统的数据库模块中查询到所述目标数据的情况下,将所述数据库模块中存储的所述目标数据发送至所述客户端;
将所述数据库模块中存储的所述目标数据存储到所述缓存模块中。
可选地,在接收客户端发送的数据查询请求之前,所述方法还包括:
建立所述存储系统中的所述内存模块,所述缓存模块和所述数据库模块;
获取所述客户端对应的目标应用的应用数据;
将所述应用数据存储到所述缓存模块和所述数据库模块中,并确定所述预设数据特征包括:数据访问频率高于目标频率,或者,数据量低于目标数据量。
可选地,在将所述应用数据存储到所述缓存模块和所述数据库模块中,并将所述应用数据中具有所述预设数据特征的数据存储到所述内存模块中之后,所述方法还包括:
接收所述目标应用发送的数据更新信息;
按照所述数据更新信息的指示对所述缓存模块和所述数据库模块中存储的数据进行更新,并删除所述内存模块中存储的数据。
可选地,在将所述应用数据存储到所述缓存模块和所述数据库模块中,并将所述应用数据中具有所述预设数据特征的数据存储到所述内存模块中之后,所述方法还包括:
每隔目标时间间隔检查所述内存模块中存储的数据的第一数据标识与所述缓存模块中存储的数据的第二数据标识是否一致;
在检查所述第一数据标识与所述第二数据标识不一致的情况下,删除所述内存模块中存储的数据。
根据本公开实施例的另一方面,还提供了一种数据的查询装置, 包括:
第一接收模块,设置为接收数据查询请求,其中,所述数据查询请求用于请求查询存储系统中的目标数据;
第一查询模块,设置为从所述存储系统的内存模块中查询所述目标数据,其中,所述存储系统包括:所述内存模块,缓存模块和数据库模块,所述缓存模块设置为缓存所述数据库模块中存储的数据,所述内存模块设置为存储所述缓存模块缓存的数据中具有预设数据特征的数据;
第一发送模块,设置为在从所述存储系统的内存模块中查询到所述目标数据的情况下,发送所述内存模块中存储的所述目标数据。
根据本公开实施例的另一方面,还提供了一种存储介质,该存储介质包括存储的程序,程序运行时执行上述的方法。
根据本公开实施例的另一方面,还提供了一种电子装置,包括存储器、处理器及存储在存储器上并可在处理器上运行的计算机程序,处理器通过计算机程序执行上述的方法。
在本公开实施例中,采用接收数据查询请求,其中,数据查询请求用于请求查询存储系统中的目标数据;从存储系统的内存模块中查询目标数据,其中,存储系统包括:内存模块,缓存模块和数据库模块,缓存模块设置为缓存数据库模块中存储的数据,内存模块设置为存储缓存模块缓存的数据中具有预设数据特征的数据;在从存储系统的内存模块中查询到目标数据的情况下,发送内存模块中存储的目标数据的方式,存储系统包括:内存模块,缓存模块和数据库模块,缓存模块设置为缓存数据库模块中存储的数据,内存模块设置为存储缓存模块缓存的数据中具有预设数据特征的数据,这样将数据库模块中的数据通过二级缓存的机制存储到缓存模块和内存模块中,在接收到数据查询请求时,优先查询内存模块,如果目标数据是具有预设数据 特征的,那么在内存模块中就可能会命中目标数据,如果命中,则返回内存模块中存储的目标数据,通过上述这种二级缓存机制,达到了快速命中数据的目的,从而实现了提高数据查询效率的技术效果,进而解决了相关技术中数据查询效率较低的技术问题。
附图说明
此处的附图被并入说明书中并构成本说明书的一部分,示出了符合本发明的实施例,并与说明书一起用于解释本发明的原理。
为了更清楚地说明本发明实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,对于本领域普通技术人员而言,在不付出创造性劳动性的前提下,还可以根据这些附图获得其他的附图。
图1是根据本公开实施例的数据的查询方法的硬件环境的示意图;
图2是根据本公开实施例的一种可选的数据的查询方法的流程图;
图3是根据本公开实施例的各种存储系统的存储架构比对的示意图;
图4是根据本公开可选实施例的一种二级缓存热点数据的流程的示意图;
图5是根据本公开实施例的一种可选的数据的查询装置的示意图;
图6是根据本公开实施例的一种终端的结构框图。
具体实施方式
为了使本技术领域的人员更好地理解本公开方案,下面将结合本公开实施例中的附图,对本公开实施例中的技术方案进行清楚、完整 地描述,显然,所描述的实施例仅仅是本公开一部分的实施例,而不是全部的实施例。基于本公开中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都应当属于本公开保护的范围。
需要说明的是,本公开的说明书和权利要求书及上述附图中的术语“第一”、“第二”等是用于区别类似的对象,而不必用于描述特定的顺序或先后次序。应该理解这样使用的数据在适当情况下可以互换,以便这里描述的本公开的实施例能够以除了在这里图示或描述的那些以外的顺序实施。此外,术语“包括”和“具有”以及他们的任何变形,意图在于覆盖不排他的包含,例如,包含了一系列步骤或单元的过程、方法、系统、产品或设备不必限于清楚地列出的那些步骤或单元,而是可包括没有清楚地列出的或对于这些过程、方法、产品或设备固有的其它步骤或单元。
根据本公开实施例的一方面,提供了一种数据的查询的方法实施例。
可选地,在本实施例中,上述数据的查询方法可以应用于如图1所示的由终端101和服务器103所构成的硬件环境中。如图1所示,服务器103通过网络与终端101进行连接,可用于为终端或终端上安装的客户端提供服务(如游戏服务、应用服务等),可在服务器上或独立于服务器设置数据库,用于为服务器103提供数据存储服务,上述网络包括但不限于:广域网、城域网或局域网,终端101并不限定于PC、手机、平板电脑等。本公开实施例的数据的查询方法可以由服务器103来执行,也可以由终端101来执行,还可以是由服务器103和终端101共同执行。其中,终端101执行本公开实施例的数据的查询方法也可以是由安装在其上的客户端来执行。
图2是根据本公开实施例的一种可选的数据的查询方法的流程图, 如图2所示,该方法可以包括以下步骤:
步骤S202,接收数据查询请求,其中,所述数据查询请求用于请求查询存储系统中的目标数据;
步骤S204,从所述存储系统的内存模块中查询所述目标数据,其中,所述存储系统包括:所述内存模块,缓存模块和数据库模块,所述缓存模块设置为缓存所述数据库模块中存储的数据,所述内存模块设置为存储所述缓存模块缓存的数据中具有预设数据特征的数据;
步骤S206,在从所述存储系统的内存模块中查询到所述目标数据的情况下,发送所述内存模块中存储的所述目标数据。
通过上述步骤S202至步骤S206,存储系统包括:内存模块,缓存模块和数据库模块,缓存模块设置为缓存数据库模块中存储的数据,内存模块设置为存储缓存模块缓存的数据中具有预设数据特征的数据,这样将数据库模块中的数据通过二级缓存的机制存储到缓存模块和内存模块中,在接收到数据查询请求时,优先查询内存模块,如果目标数据是具有预设数据特征的,那么在内存模块中就可能会命中目标数据,如果命中,则返回内存模块中存储的目标数据,通过上述这种二级缓存机制,达到了快速命中数据的目的,从而实现了提高数据查询效率的技术效果,进而解决了相关技术中数据查询效率较低的技术问题。
在步骤S202提供的技术方案中,数据查询请求可以但不限于是由客户端发送的,也可以是服务器发送的,客户端可以但不限于包括各种功能应用的客户端,比如:在线教育应用、即时通讯应用、社区空间应用、游戏应用、购物应用、浏览器应用、金融应用、多媒体应用、直播应用等。
可选地,在本实施例中,数据查询请求用于请求查询存储系统中的目标数据,目标数据可以但不限于包括商品信息、音视频文件、聊 天记录、交易信息等等。
在步骤S204提供的技术方案中,存储系统包括:内存模块,缓存模块和数据库模块,缓存模块设置为缓存数据库模块中存储的数据,内存模块设置为存储缓存模块缓存的数据中具有预设数据特征的数据。缓存模块中缓存数据库中的全量数据,并将缓存模块缓存的数据中具有预设数据特征的数据存储在内存模块中,当接收到数据查询请求时,首先在内存模块存储的具有预设数据特征的数据中查询,如果命中则可以直接返回。
可选地,在本实施例中,预设数据特征可以但不限于用于表示数据的属性特征,比如:数据量、数据访问频率、数据的敏感度等等。
在步骤S206提供的技术方案中,如果内存模块中命中了目标数据,则可以直接返回。
在一个可选的实施方式中,提供了一种存储系统的存储架构,图3是根据本公开实施例的各种存储系统的存储架构比对的示意图,如图3所示,存储系统(a)的架构只使用DB(数据库模块),这种方案的缺点是DB的压力会很大,性能也很差。存储系统(b)的架构使用了内存模块(cacha)和数据库模块(DB),它的缺点就是内存压力大,还有就是对ZK的强依赖。现有技术中使用存储系统(a)和存储系统(b)进行数据存储,数据的查询效率都比较低。
在本可选的实施方式中提供了存储系统(c)的架构,该存储系统架构是读写分离的,把一个单应用产品的读写拆分成读和写两个应用,之间的同步是通过ZK(一种网页应用程序开发框架)做zookeeper(动物园管理员协调服务)和定时任务(QUARTZ)来保证同步。这样带来的优点是解耦的高可用,第二个是缓存的高性能。
存储系统(a)和存储系统(b)本均采用单一应用处理系统内外部读写逻辑,存储系统(c)中将写应用(数据库模块(DB))与读应 用(内存模块+缓存模块(cache+R2M))分开,DB服务处理管理后台(console)的读写操作和cache+R2M应用的读请求(即系统内部读写请求),cache+R2M服务统一处理外部应用(web)的读请求,本次读写分离中的读主要指外部应用的读请求。
作为一种可选的实施例,在从所述存储系统的内存模块中查询所述目标数据之后,还包括:
S1,在从所述存储系统的内存模块中未查询到所述目标数据的情况下,从所述存储系统的缓存模块查询所述目标数据;
S2,在从所述存储系统的缓存模块中查询到所述目标数据的情况下,发送所述缓存模块中存储的所述目标数据。
可选地,在本实施例中,如果内存模块中没有命中目标数据,则从缓存模块中进行查询,如果缓存模块中查到目标数据,则返回缓存模块中存储的目标数据。
作为一种可选的实施例,在从所述存储系统的缓存模块查询所述目标数据之后,还包括:
S1,在从所述存储系统的缓存模块中查询到所述目标数据的情况下,确定所述目标数据是否具有所述预设数据特征;
S2,在确定所述目标数据具有所述预设数据特征的情况下,将所述目标数据存储到所述内存模块中。
可选地,在本实施例中,如果在缓存模块查到了目标数据,则确定该目标数据是否适合存储在内存中,即目标数据是否具有预设数据特征。如果目标数据具有预设数据特征,则将其添加到内存中,那么在后续的查询中则可以直接在内存中命中该目标数据,提高查询的效率。
作为一种可选的实施例,在从所述存储系统的缓存模块查询所述 目标数据之后,还包括:
S1,在从所述存储系统的缓存模块中未查询到所述目标数据的情况下,从所述存储系统的数据库模块查询所述目标数据;
S2,在从所述存储系统的数据库模块中查询到所述目标数据的情况下,将所述数据库模块中存储的所述目标数据发送至所述客户端;
S3,将所述数据库模块中存储的所述目标数据存储到所述缓存模块中。
可选地,在本实施例中,如果缓存中也没有查询到目标数据,则查找数据库,并将数据库中查找到的目标数据缓存到缓存模块中。
作为一种可选的实施例,在接收客户端发送的数据查询请求之前,还包括:
S1,建立所述存储系统中的所述内存模块,所述缓存模块和所述数据库模块;
S2,获取所述客户端对应的目标应用的应用数据;
S3,将所述应用数据存储到所述缓存模块和所述数据库模块中,并确定所述预设数据特征包括:数据访问频率高于目标频率,或者,数据量低于目标数据量。
可选地,在本实施例中,内存模块可以但不限于设置为存储热点数据,缓存模块存储全量数据。在设置缓存策略时,先划分好热点与非热点数据,热点数据可以但不限于定义为:频繁访问(如产品、责任、条款),非大容量字段(如全国地区码表、费率表等为大容量字段)。在系统开发阶段,针对业务表会设置缓存块,如果业务表为热点数据,则进行二级缓存处理(内存+缓存),非热点数据则只进行一级缓存(即只走缓存、不走内存)处理,节省内存空间。这里热点数据的判断可以不是系统动态判断,而是开发时提前设置好的。
采用这种高频热点数据二级缓存,低频、大数据一级缓存的热点缓存机制,二级缓存可提升服务高并发高可用能力,热点缓存可提升内存利用率,优先保证热点数据的高效并发。
作为一种可选的实施例,在将所述应用数据存储到所述缓存模块和所述数据库模块中,并将所述应用数据中具有所述预设数据特征的数据存储到所述内存模块中之后,还包括:
S1,接收所述目标应用发送的数据更新信息;
S2,按照所述数据更新信息的指示对所述缓存模块和所述数据库模块中存储的数据进行更新,并删除所述内存模块中存储的数据。
可选地,在本实施例中,如果接收到数据更新信息,则同步更新缓存模块和数据库,并清空内存。后续接收到数据查询请求时,内存模块中查不到数据,则在缓存模块中进行查询,并将具有预设数据特征的数据存储到内存模块中,从而保证了数据的一致性,实现了数据的同步更新。
在上述可选的实施方式中提供了数据实时同步过程,写数据成功后(数据写入数据库,再将数据与数据版本写入R2M缓存),写应用(base)通过Zookeeper分布式服务中间件的广播通知机制,将更新节点(如产品)写入ZK配置,通知读应用(cache)各实例监听广播通知,根据通知节点删除各实例下的内存数据(如产品),保证数据强一致性。
作为一种可选的实施例,在将所述应用数据存储到所述缓存模块和所述数据库模块中,并将所述应用数据中具有所述预设数据特征的数据存储到所述内存模块中之后,还包括:
S1,每隔目标时间间隔检查所述内存模块中存储的数据的第一数据标识与所述缓存模块中存储的数据的第二数据标识是否一致;
S2,在检查所述第一数据标识与所述第二数据标识不一致的情况下,删除所述内存模块中存储的数据。
可选地,在本实施例中,目标时间间隔可以是预先设置的,也可以是根据数据的历史处理信息进行动态调整的。
可选地,在本实施例中,每隔目标时间间隔查询内存和缓存中存储的数据的数据标识是否一致,并对不一致的情况进行处理,保证了数据的一致性,实现了数据的定是同步。
可选地,在本实施例中,上述数据标识用于对数据的版本进行唯一标识,可以但不限于使用版本号作为上述数据标识。
在上述可选的实施方式中提供了数据定时同步过程,每间隔半小时(时间可自定义)轮询读应用(cache)各缓存块存入内存的数据版本与存入缓存(R2M)的数据版本是否一致,不一致则认为内存数据为未更新的旧数据,将该内存数据删除。定时同步可以防止ZK同步异常或其他原因造成的数据不一致,从而保证一定时间范围的数据一致性。
本公开还提供了一种可选实施例,该可选实施例提供一种二级缓存热点数据的处理流程,图4是根据本公开可选实施例的一种二级缓存热点数据的流程的示意图,如图4所示,可以看到产品查询的时候,查询顺序可以是内存模块(例如使用cache存储热点数据[hot])、缓存模块(例如可以使用Redis,即R2M)、数据库模块(例如使用MongoDB(一种基于分布式文件存储的数据库),可以通过MySQL(一种关系数据库管理系统)进行备份),当产品更新(UPDATE)的时候会去刷新缓存模块(R2M),然后同时删除(DEL)内存模块(cache)中的数据,并通过版本检查任务,定时去检查(CHECK)缓存模块和内存模块的数据是否一致,如果不一致则清空内存模块,保证数据一致性。数据更新的时候,都会保证把更新后的数据刷到缓存模块里面去,但是内存模块通过ZK去通知,进行删除(DEL)操作。
上述的二级缓存机制的过程为:内存——缓存——DB。本可选实施例中,把缓存模块和内存模块同时引用进来,做了一个二级的热点数据缓存,二级缓存的查询方案可以是:将部分热点数据存储在内存模块、全量数据存储在缓存模块,然后DB数据库模块作为一个备用查询方式,查询的顺序是首先查内存模块,如果内存模块存在查询的数据就直接返回,不存在就查缓存模块,如果是热点数据,则在查完缓存模块后把缓存模块的数据写进内存模块;如果缓存模块中不存在查询的数据,再去查数据库模块,然后把数据库模块的数据再覆盖到缓存模块上。这样就可以实现逐级的查询,并且每一级的查询量都会呈现数量级的递减,因为大部分的查询都能够被内存模块击中,内存模块的查询成功率会很高,然后部分的大数据或者说数据请求量较小的数据放在缓存模块里面进行查询。
上述流程还提供了数据更新机制和灾备机制,数据更新并发更新数据库模块与缓存模块,然后异步广播删除内存模块的数据,保证数据一致性。对于数据版本检查,开启定时版本检查任务,将热点数据的版本号同时进行二级缓存,防止因广播通知等原因造成二级缓存数据不一致,允许一定时间内数据不一致,但最终数据一致。
现有的查询内存的方案,如果查询的数据不存在,就直接返回错误,存在问题就是有可能是因为内存和数据库的数据不一致导致的,即有可能数据库数据发生了更新,但没有及时通知到内存,之前是用ZK的方式,就是使用zookeeper框架内通知的,如果zookeeper框架出现问题就会导致内存的数据和数据库的数据不一致,产生脏数据问题,本可选实施例使用两种方式,一种还是ZK,就是利用zookeeper的广播通知;另外一种方式是使用版本检查的任务,该任务就是每隔一段时间就会去检查版本号,在版本号不一致的情况下去检查缓存模块和内存模块的数据,如果数据不一致,会自动去更新内存模块和缓存模块,这样就保证了在一定时间内数据的一致性。
通过本可选实施例的流程,能够提高服务的高并发和高可用的能力,提高内存的使用效率,譬如,实际测试中以前内存使用率达到了50%,甚至可能会达到80%,在使用本可选实施例提供的缓存机制后内存使用率达到30%以下。
在本可选实施例中,采用二级热点缓存方案,增强服务并发能力的同时提升内存利用率,同时在二级缓存的基础上增加灾备机制,保证数据最终一致性。
需要说明的是,对于前述的各方法实施例,为了简单描述,故将其都表述为一系列的动作组合,但是本领域技术人员应该知悉,本公开并不受所描述的动作顺序的限制,因为依据本公开,某些步骤可以采用其他顺序或者同时进行。其次,本领域技术人员也应该知悉,说明书中所描述的实施例均属于可选实施例,所涉及的动作和模块并不一定是本公开所必须的。
通过以上的实施方式的描述,本领域的技术人员可以清楚地了解到根据上述实施例的方法可借助软件加必需的通用硬件平台的方式来实现,当然也可以通过硬件,但很多情况下前者是更佳的实施方式。基于这样的理解,本公开的技术方案本质上或者说对现有技术做出贡献的部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质(如ROM/RAM、磁碟、光盘)中,包括若干指令用以使得一台终端设备(可以是手机,计算机,服务器,或者网络设备等)执行本公开各个实施例所述的方法。
根据本公开实施例的另一个方面,还提供了一种用于实施上述数据的查询方法的数据的查询装置。图5是根据本公开实施例的一种可选的数据的查询装置的示意图,如图5所示,该装置可以包括:
第一接收模块52,设置为接收数据查询请求,其中,所述数据查 询请求用于请求查询存储系统中的目标数据;
第一查询模块54,设置为从所述存储系统的内存模块中查询所述目标数据,其中,所述存储系统包括:所述内存模块,缓存模块和数据库模块,所述缓存模块设置为缓存所述数据库模块中存储的数据,所述内存模块设置为存储所述缓存模块缓存的数据中具有预设数据特征的数据;
第一发送模块56,设置为在从所述存储系统的内存模块中查询到所述目标数据的情况下,发送所述内存模块中存储的所述目标数据。
需要说明的是,该实施例中的第一接收模块52可以设置为执行本公开实施例中的步骤S202,该实施例中的第一查询模块54可以设置为执行本公开实施例中的步骤S204,该实施例中的第一发送模块56可以设置为执行本公开实施例中的步骤S206。
此处需要说明的是,上述模块与对应的步骤所实现的示例和应用场景相同,但不限于上述实施例所公开的内容。需要说明的是,上述模块作为装置的一部分可以运行在如图1所示的硬件环境中,可以通过软件实现,也可以通过硬件实现。
通过上述模块,存储系统包括:内存模块,缓存模块和数据库模块,缓存模块设置为缓存数据库模块中存储的数据,内存模块设置为存储缓存模块缓存的数据中具有预设数据特征的数据,这样将数据库模块中的数据通过二级缓存的机制存储到缓存模块和内存模块中,在接收到数据查询请求时,优先查询内存模块,如果目标数据是具有预设数据特征的,那么在内存模块中就可能会命中目标数据,如果命中,则返回内存模块中存储的目标数据,通过上述这种二级缓存机制,达到了快速命中数据的目的,从而实现了提高数据查询效率的技术效果,进而解决了相关技术中数据查询效率较低的技术问题。
作为一种可选的实施例,所述装置还包括:
第二查询模块,设置为在从所述存储系统的内存模块中查询所述目标数据之后,在从所述存储系统的内存模块中未查询到所述目标数据的情况下,从所述存储系统的缓存模块查询所述目标数据;
第二发送模块,设置为在从所述存储系统的缓存模块中查询到所述目标数据的情况下,发送所述缓存模块中存储的所述目标数据。
作为一种可选的实施例,所述装置还包括:
确定模块,设置为在从所述存储系统的缓存模块查询所述目标数据之后,在从所述存储系统的缓存模块中查询到所述目标数据的情况下,确定所述目标数据是否具有所述预设数据特征;
第一存储模块,设置为在确定所述目标数据具有所述预设数据特征的情况下,将所述目标数据存储到所述内存模块中。
作为一种可选的实施例,所述装置还包括:
第三查询模块,设置为在从所述存储系统的缓存模块查询所述目标数据之后,在从所述存储系统的缓存模块中未查询到所述目标数据的情况下,从所述存储系统的数据库模块查询所述目标数据;
第三发送模块,设置为在从所述存储系统的数据库模块中查询到所述目标数据的情况下,将所述数据库模块中存储的所述目标数据发送至所述客户端;
第二存储模块,设置为将所述数据库模块中存储的所述目标数据存储到所述缓存模块中。
作为一种可选的实施例,所述装置还包括:
建立模块,设置为在接收客户端发送的数据查询请求之前,建立所述存储系统中的所述内存模块,所述缓存模块和所述数据库模块;
获取模块,设置为获取所述客户端对应的目标应用的应用数据;
第三存储模块,设置为将所述应用数据存储到所述缓存模块和所述数据库模块中,并确定所述预设数据特征包括:数据访问频率高于目标频率,或者,数据量低于目标数据量。
作为一种可选的实施例,所述装置还包括:
第二接收模块,设置为在将所述应用数据存储到所述缓存模块和所述数据库模块中,并将所述应用数据中具有所述预设数据特征的数据存储到所述内存模块中之后,接收所述目标应用发送的数据更新信息;
更新模块,设置为按照所述数据更新信息的指示对所述缓存模块和所述数据库模块中存储的数据进行更新,并删除所述内存模块中存储的数据。
作为一种可选的实施例,所述装置还包括:
检查模块,设置为在将所述应用数据存储到所述缓存模块和所述数据库模块中,并将所述应用数据中具有所述预设数据特征的数据存储到所述内存模块中之后,每隔目标时间间隔检查所述内存模块中存储的数据的第一数据标识与所述缓存模块中存储的数据的第二数据标识是否一致;
删除模块,设置为在检查所述第一数据标识与所述第二数据标识不一致的情况下,删除所述内存模块中存储的数据。
此处需要说明的是,上述模块与对应的步骤所实现的示例和应用场景相同,但不限于上述实施例所公开的内容。需要说明的是,上述模块作为装置的一部分可以运行在如图1所示的硬件环境中,可以通过软件实现,也可以通过硬件实现,其中,硬件环境包括网络环境。
根据本公开实施例的另一个方面,还提供了一种用于实施上述数 据的查询方法的服务器或终端。
图6是根据本公开实施例的一种终端的结构框图,如图6所示,该终端可以包括:一个或多个(图中仅示出一个)处理器601、存储器603、以及传输装置605,如图6所示,该终端还可以包括输入输出设备607。
其中,存储器603可设置为存储软件程序以及模块,如本公开实施例中的数据的查询方法和装置对应的程序指令/模块,处理器601通过运行存储在存储器603内的软件程序以及模块,从而执行各种功能应用以及数据处理,即实现上述的数据的查询方法。存储器603可包括高速随机存储器,还可以包括非易失性存储器,如一个或者多个磁性存储装置、闪存、或者其他非易失性固态存储器。在一些实例中,存储器603可进一步包括相对于处理器601远程设置的存储器,这些远程存储器可以通过网络连接至终端。上述网络的实例包括但不限于互联网、企业内部网、局域网、移动通信网及其组合。
上述的传输装置605设置为经由一个网络接收或者发送数据,还可以设置为处理器与存储器之间的数据传输。上述的网络可选实例可包括有线网络及无线网络。在一个实例中,传输装置605包括一个网络适配器(Network Interface Controller,NIC),其可通过网线与其他网络设备与路由器相连从而可与互联网或局域网进行通讯。在一个实例中,传输装置605为射频(Radio Frequency,RF)模块,其设置为通过无线方式与互联网进行通讯。
其中,可选地,存储器603设置为存储应用程序。
处理器601可以通过传输装置605调用存储器603存储的应用程序,以执行下述步骤:
S1,接收数据查询请求,其中,所述数据查询请求用于请求查询存储系统中的目标数据;
S2,从所述存储系统的内存模块中查询所述目标数据,其中,所述存储系统包括:所述内存模块,缓存模块和数据库模块,所述缓存模块设置为缓存所述数据库模块中存储的数据,所述内存模块设置为存储所述缓存模块缓存的数据中具有预设数据特征的数据;
S3,在从所述存储系统的内存模块中查询到所述目标数据的情况下,发送所述内存模块中存储的所述目标数据。
采用本公开实施例,提供了一种数据的查询的方案。存储系统包括:内存模块,缓存模块和数据库模块,缓存模块设置为缓存数据库模块中存储的数据,内存模块设置为存储缓存模块缓存的数据中具有预设数据特征的数据,这样将数据库模块中的数据通过二级缓存的机制存储到缓存模块和内存模块中,在接收到数据查询请求时,优先查询内存模块,如果目标数据是具有预设数据特征的,那么在内存模块中就可能会命中目标数据,如果命中,则返回内存模块中存储的目标数据,通过上述这种二级缓存机制,达到了快速命中数据的目的,从而实现了提高数据查询效率的技术效果,进而解决了相关技术中数据查询效率较低的技术问题。
可选地,本实施例中的可选示例可以参考上述实施例中所描述的示例,本实施例在此不再赘述。
本领域普通技术人员可以理解,图6所示的结构仅为示意,终端可以是智能手机(如Android手机、iOS手机等)、平板电脑、掌上电脑以及移动互联网设备(Mobile Internet Devices,MID)、PAD等终端设备。图6其并不对上述电子装置的结构造成限定。例如,终端还可包括比图6中所示更多或者更少的组件(如网络接口、显示装置等),或者具有与图6所示不同的配置。
本领域普通技术人员可以理解上述实施例的各种方法中的全部或部分步骤是可以通过程序来指令终端设备相关的硬件来完成,该程序 可以存储于一计算机可读存储介质中,存储介质可以包括:闪存盘、只读存储器(Read-Only Memory,ROM)、随机存取器(Random Access Memory,RAM)、磁盘或光盘等。
本公开的实施例还提供了一种存储介质。可选地,在本实施例中,上述存储介质可以用于执行数据的查询方法的程序代码。
可选地,在本实施例中,上述存储介质可以位于上述实施例所示的网络中的多个网络设备中的至少一个网络设备上。
可选地,在本实施例中,存储介质被设置为存储用于执行以下步骤的程序代码:
S1,接收数据查询请求,其中,所述数据查询请求用于请求查询存储系统中的目标数据;
S2,从所述存储系统的内存模块中查询所述目标数据,其中,所述存储系统包括:所述内存模块,缓存模块和数据库模块,所述缓存模块设置为缓存所述数据库模块中存储的数据,所述内存模块设置为存储所述缓存模块缓存的数据中具有预设数据特征的数据;
S3,在从所述存储系统的内存模块中查询到所述目标数据的情况下,发送所述内存模块中存储的所述目标数据。
可选地,本实施例中的可选示例可以参考上述实施例中所描述的示例,本实施例在此不再赘述。
可选地,在本实施例中,上述存储介质可以包括但不限于:U盘、只读存储器(ROM,Read-Only Memory)、随机存取存储器(RAM,Random Access Memory)、移动硬盘、磁碟或者光盘等各种可以存储程序代码的介质。
上述本公开实施例序号仅仅为了描述,不代表实施例的优劣。
上述实施例中的集成的单元如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在上述计算机可读取的存储介质中。基于这样的理解,本公开的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的全部或部分可以以软件产品的形式体现出来,该计算机软件产品存储在存储介质中,包括若干指令用以使得一台或多台计算机设备(可为个人计算机、服务器或者网络设备等)执行本公开各个实施例所述方法的全部或部分步骤。
在本公开的上述实施例中,对各个实施例的描述都各有侧重,某个实施例中没有详述的部分,可以参见其他实施例的相关描述。
在本公开所提供的几个实施例中,应该理解到,所揭露的客户端,可通过其它的方式实现。其中,以上所描述的装置实施例仅仅是示意性的,例如所述单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,单元或模块的间接耦合或通信连接,可以是电性或其它的形式。
所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。
另外,在本公开各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用软件功能单元的形式实现。
以上所述仅是本公开的可选实施方式,应当指出,对于本技术领 域的普通技术人员来说,在不脱离本公开原理的前提下,还可以做出若干改进和润饰,这些改进和润饰也应视为本公开的保护范围。

Claims (10)

  1. 一种数据的查询方法,包括:
    接收数据查询请求,其中,所述数据查询请求用于请求查询存储系统中的目标数据;
    从所述存储系统的内存模块中查询所述目标数据,其中,所述存储系统包括:所述内存模块,缓存模块和数据库模块,所述缓存模块设置为缓存所述数据库模块中存储的数据,所述内存模块设置为存储所述缓存模块缓存的数据中具有预设数据特征的数据;
    在从所述存储系统的内存模块中查询到所述目标数据的情况下,发送所述内存模块中存储的所述目标数据。
  2. 根据权利要求1所述的方法,其中,在从所述存储系统的内存模块中查询所述目标数据之后,所述方法还包括:
    在从所述存储系统的内存模块中未查询到所述目标数据的情况下,从所述存储系统的缓存模块查询所述目标数据;
    在从所述存储系统的缓存模块中查询到所述目标数据的情况下,发送所述缓存模块中存储的所述目标数据。
  3. 根据权利要求2所述的方法,其中,在从所述存储系统的缓存模块查询所述目标数据之后,所述方法还包括:
    在从所述存储系统的缓存模块中查询到所述目标数据的情况下,确定所述目标数据是否具有所述预设数据特征;
    在确定所述目标数据具有所述预设数据特征的情况下,将所述目标数据存储到所述内存模块中。
  4. 根据权利要求2所述的方法,其中,在从所述存储系统的缓存模块查询所述目标数据之后,所述方法还包括:
    在从所述存储系统的缓存模块中未查询到所述目标数据的情况下,从所述存储系统的数据库模块查询所述目标数据;
    在从所述存储系统的数据库模块中查询到所述目标数据的情况下,将所述数据库模块中存储的所述目标数据发送至所述客户端;
    将所述数据库模块中存储的所述目标数据存储到所述缓存模块中。
  5. 根据权利要求1所述的方法,其中,在接收客户端发送的数据查询请求之前,所述方法还包括:
    建立所述存储系统中的所述内存模块,所述缓存模块和所述数据库模块;
    获取所述客户端对应的目标应用的应用数据;
    将所述应用数据存储到所述缓存模块和所述数据库模块中,并确定所述预设数据特征包括:数据访问频率高于目标频率,或者,数据量低于目标数据量。
  6. 根据权利要求5所述的方法,其中,在将所述应用数据存储到所述缓存模块和所述数据库模块中,并将所述应用数据中具有所述预设数据特征的数据存储到所述内存模块中之后,所述方法还包括:
    接收所述目标应用发送的数据更新信息;
    按照所述数据更新信息的指示对所述缓存模块和所述数据库模块中存储的数据进行更新,并删除所述内存模块中存储的数据。
  7. 根据权利要求5所述的方法,其中,在将所述应用数据存储到所述缓存模块和所述数据库模块中,并将所述应用数据中具有所述预设数据特征的数据存储到所述内存模块中之后,所述方法还包括:
    每隔目标时间间隔检查所述内存模块中存储的数据的第一数据标 识与所述缓存模块中存储的数据的第二数据标识是否一致;
    在检查所述第一数据标识与所述第二数据标识不一致的情况下,删除所述内存模块中存储的数据。
  8. 一种数据的查询装置,包括:
    第一接收模块,设置为接收数据查询请求,其中,所述数据查询请求用于请求查询存储系统中的目标数据;
    第一查询模块,设置为从所述存储系统的内存模块中查询所述目标数据,其中,所述存储系统包括:所述内存模块,缓存模块和数据库模块,所述缓存模块设置为缓存所述数据库模块中存储的数据,所述内存模块设置为存储所述缓存模块缓存的数据中具有预设数据特征的数据;
    第一发送模块,设置为在从所述存储系统的内存模块中查询到所述目标数据的情况下,发送所述内存模块中存储的所述目标数据。
  9. 一种存储介质,所述存储介质包括存储的程序,其中,所述程序运行时执行上述权利要求1至7任一项中所述的方法。
  10. 一种电子装置,包括存储器、处理器及存储在所述存储器上并可在所述处理器上运行的计算机程序,所述处理器通过所述计算机程序执行上述权利要求1至7任一项中所述的方法。
PCT/CN2021/072678 2020-02-20 2021-01-19 一种数据的查询方法和装置 WO2021164487A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202010105429.2A CN111291079A (zh) 2020-02-20 2020-02-20 一种数据的查询方法和装置
CN202010105429.2 2020-02-20

Publications (1)

Publication Number Publication Date
WO2021164487A1 true WO2021164487A1 (zh) 2021-08-26

Family

ID=71026786

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2021/072678 WO2021164487A1 (zh) 2020-02-20 2021-01-19 一种数据的查询方法和装置

Country Status (2)

Country Link
CN (1) CN111291079A (zh)
WO (1) WO2021164487A1 (zh)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114117187A (zh) * 2022-01-25 2022-03-01 深圳希施玛数据科技有限公司 数据查询方法及相关装置

Families Citing this family (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111291079A (zh) * 2020-02-20 2020-06-16 京东数字科技控股有限公司 一种数据的查询方法和装置
CN112163001A (zh) * 2020-09-25 2021-01-01 同程网络科技股份有限公司 高并发查询方法、智能终端及存储介质
CN112398852B (zh) * 2020-11-12 2022-11-15 北京天融信网络安全技术有限公司 一种报文检测方法、装置、存储介质和电子设备
CN112398849B (zh) * 2020-11-12 2022-12-20 北京天融信网络安全技术有限公司 一种嵌入式威胁情报数据集的更新方法及装置
CN112540984B (zh) * 2020-11-23 2023-10-03 成都佳华物链云科技有限公司 数据存储方法、查询方法、装置、电子设备及存储介质
CN112579630A (zh) * 2020-12-28 2021-03-30 北京思特奇信息技术股份有限公司 一种商品检索方法、系统及电子设备
CN112685634A (zh) * 2020-12-29 2021-04-20 平安普惠企业管理有限公司 数据查询方法、装置、电子设备及存储介质
CN113127451A (zh) * 2021-05-10 2021-07-16 广州欢网科技有限责任公司 后台快速查询和加载数据的方法和系统
CN114138807B (zh) * 2021-12-06 2024-04-12 四三九九网络股份有限公司 一种实时更新数据库热点数据缓存的方法
CN114328466A (zh) * 2022-01-06 2022-04-12 北京微吼时代科技有限公司 一种数据冷热存储的方法、装置及电子设备
CN115101219A (zh) * 2022-06-27 2022-09-23 康键信息技术(深圳)有限公司 问诊系统的数据处理方法、装置及电子设备

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104753966A (zh) * 2013-12-25 2015-07-01 明博教育科技有限公司 一种基于服务器和客户端缓存的资源文件查询方法及系统
CN108780458A (zh) * 2017-12-08 2018-11-09 深圳市大疆创新科技有限公司 一种页面缓存处理方法、装置和服务器
CN108874806A (zh) * 2017-05-09 2018-11-23 广东神马搜索科技有限公司 数据查询方法、装置及数据存储系统
CN109933585A (zh) * 2019-02-22 2019-06-25 京东数字科技控股有限公司 数据查询方法和数据查询系统
CN111291079A (zh) * 2020-02-20 2020-06-16 京东数字科技控股有限公司 一种数据的查询方法和装置

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107644071A (zh) * 2017-09-18 2018-01-30 广州爱九游信息技术有限公司 缓存更新方法、装置及数据存储系统
CN109947668B (zh) * 2017-12-21 2021-06-29 北京京东尚科信息技术有限公司 存储数据的方法和装置
CN109558421A (zh) * 2018-10-29 2019-04-02 中国建设银行股份有限公司 基于缓存的数据处理方法、系统、装置及存储介质

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104753966A (zh) * 2013-12-25 2015-07-01 明博教育科技有限公司 一种基于服务器和客户端缓存的资源文件查询方法及系统
CN108874806A (zh) * 2017-05-09 2018-11-23 广东神马搜索科技有限公司 数据查询方法、装置及数据存储系统
CN108780458A (zh) * 2017-12-08 2018-11-09 深圳市大疆创新科技有限公司 一种页面缓存处理方法、装置和服务器
CN109933585A (zh) * 2019-02-22 2019-06-25 京东数字科技控股有限公司 数据查询方法和数据查询系统
CN111291079A (zh) * 2020-02-20 2020-06-16 京东数字科技控股有限公司 一种数据的查询方法和装置

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114117187A (zh) * 2022-01-25 2022-03-01 深圳希施玛数据科技有限公司 数据查询方法及相关装置
CN114117187B (zh) * 2022-01-25 2022-06-21 深圳希施玛数据科技有限公司 数据查询方法及相关装置

Also Published As

Publication number Publication date
CN111291079A (zh) 2020-06-16

Similar Documents

Publication Publication Date Title
WO2021164487A1 (zh) 一种数据的查询方法和装置
CN102541990B (zh) 利用虚拟分区的数据库重新分布方法和系统
CN106933550B (zh) 全局信息获取、处理及更新方法、装置和系统
US20070124437A1 (en) Method and system for real-time collection of log data from distributed network components
US10795577B2 (en) De-duplication of client-side data cache for virtual disks
CN111177165B (zh) 数据一致性检测的方法、装置及设备
WO2018058949A1 (zh) 一种数据存储方法、装置及系统
CN106302595B (zh) 一种对服务器进行健康检查的方法及设备
US20170329527A1 (en) Global de-duplication of virtual disks in a storage platform
CN106933548B (zh) 全局信息获取、处理及更新、方法、装置和系统
TWI734744B (zh) 路由表的同步方法、裝置及系統
CN101867607A (zh) 一种分布式数据存取方法、装置及系统
WO2021147935A1 (zh) 一种日志回放方法及装置
US20100153346A1 (en) Data integrity in a database environment through background synchronization
CN104252466A (zh) 流计算处理方法、设备和系统
CN109167840B (zh) 一种任务推送方法、节点自治服务器及边缘缓存服务器
CN110196759B (zh) 分布式事务处理方法和装置、存储介质及电子装置
CN104954444B (zh) 一种迁移缓存数据的方法及设备
CN113806300B (zh) 数据存储方法、系统、装置、设备及存储介质
CN110489388A (zh) 一种用于分布式网络存储系统中scsi锁的实现方法及设备
CN111049928A (zh) 数据同步方法、系统、电子设备及计算机可读存储介质
CN101344882B (zh) 数据查询方法、插入方法及删除方法
CN112148206A (zh) 一种数据读写方法、装置、电子设备及介质
CN107181773A (zh) 分布式存储系统的数据存储及数据管理方法、设备
CN105610921B (zh) 一种集群下基于数据缓存的纠删码归档方法

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 21757980

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 21757980

Country of ref document: EP

Kind code of ref document: A1

122 Ep: pct application non-entry in european phase

Ref document number: 21757980

Country of ref document: EP

Kind code of ref document: A1