CN113535769B - Method and device for inquiring information - Google Patents

Method and device for inquiring information Download PDF

Info

Publication number
CN113535769B
CN113535769B CN202010295677.8A CN202010295677A CN113535769B CN 113535769 B CN113535769 B CN 113535769B CN 202010295677 A CN202010295677 A CN 202010295677A CN 113535769 B CN113535769 B CN 113535769B
Authority
CN
China
Prior art keywords
information
time period
user
database
time
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202010295677.8A
Other languages
Chinese (zh)
Other versions
CN113535769A (en
Inventor
王瑞
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Jingdong Zhenshi Information Technology Co Ltd
Original Assignee
Beijing Jingdong Zhenshi Information Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Jingdong Zhenshi Information Technology Co Ltd filed Critical Beijing Jingdong Zhenshi Information Technology Co Ltd
Priority to CN202010295677.8A priority Critical patent/CN113535769B/en
Publication of CN113535769A publication Critical patent/CN113535769A/en
Application granted granted Critical
Publication of CN113535769B publication Critical patent/CN113535769B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

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
    • 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
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • 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)

Abstract

The invention discloses a method and a device for inquiring information, and relates to the technical field of computers. One embodiment of the method comprises the following steps: acquiring first information and first time based on a query request; if the cache database stores the first information, acquiring second information and a first time period which are stored in a matching way with the first information from the cache database; if the first time period comprises the first time, determining the second information as a response result of the query request; wherein the second information matches the first time period. According to the embodiment, the information amount in the cache database is reduced, the space occupied by the cache database is reduced, the access times of the database are reduced, and the query efficiency is improved.

Description

Method and device for inquiring information
Technical Field
The present invention relates to the field of computer technologies, and in particular, to a method and an apparatus for querying information.
Background
The existing information query process comprises the following steps: acquiring information I based on the query request; if the cache database stores the first information, acquiring the second information which is stored in a matching way with the first information from the cache database, and determining the second information as a response result.
In the process of implementing the present invention, the inventor finds that at least the following problems exist in the prior art:
if the content of the first information acquired by the first query is the same as that of the second information, the cache database stores two identical pieces of information, so that the problems of large information quantity and large occupied space of the cache database exist. In addition, the database needs to be accessed for multiple times to obtain the response result of the second query, so that the problems of multiple times of database access and low query efficiency are also caused.
Disclosure of Invention
In view of this, the embodiments of the present invention provide a method and an apparatus for querying information, which can reduce the information amount in a cache database, reduce the space occupied by the cache database, reduce the access times of the database, and improve the query efficiency.
To achieve the above object, according to one aspect of the embodiments of the present invention, there is provided a method of querying information.
The method for inquiring the information provided by the embodiment of the invention comprises the following steps:
acquiring first information and first time based on a query request;
if the cache database stores the first information, acquiring second information and a first time period which are stored in a matching way with the first information from the cache database; if the first time period comprises the first time, determining the second information as a response result of the query request; wherein the second information matches the first time period.
In one embodiment, further comprising:
if the first information does not exist in the cache database, acquiring second information matched with the first information from the database and a first time period matched with the second information; storing the first information, the second information and the first time period in the cache database in a matching way; and determining the second information as a response result of the query request.
In one embodiment, obtaining first information and a first time based on a query request includes:
receiving a query request, wherein the query request carries an identifier of a user, a service type, an identifier of an article of the user and a first time;
and acquiring the value of the target attribute of the article based on the identification of the user, the identification of the article of the user and the first time, and combining the identification of the user, the service type and the value of the target attribute of the article into first information.
In one embodiment, obtaining a value of a target attribute of an item of the user based on an identification of the item, and the first time comprises:
querying a summary of an information table from the database, wherein the summary comprises an identification of the user, and the validity period of the summary comprises the first time;
Acquiring target attributes from the abstract;
and acquiring the value of the target attribute of the object according to the identification of the object of the user and the target attribute.
In one embodiment, retrieving second information from a database that matches the first information includes:
acquiring the identification of the abstract from the abstract;
querying the information table containing the identification of the abstract from a database;
and obtaining information matched with the service type and the value of the object attribute of the article from the information table, and determining the information as second information matched with the first information.
In one embodiment, the method for determining the first time period includes:
and determining the intersection of the validity period of the abstract and the service processing time period as the first time period, or directly determining the validity period of the abstract as the first time period.
In one embodiment, storing the first information, and the second information and the first time period match in the cache database includes:
and taking the first information as a key, taking the second information and the first time period as values, and storing the second information and the first time period in the cache database in a matching manner in a key value manner.
To achieve the above object, according to another aspect of an embodiment of the present invention, there is provided an apparatus for querying information.
The device for inquiring information in the embodiment of the invention comprises the following components:
the first processing unit is used for acquiring first information and first time based on the query request;
the second processing unit is used for acquiring second information and a first time period which are stored in a matching way with the first information from the cache database if the cache database stores the first information; if the first time period comprises the first time, determining the second information as a response result of the query request; wherein the second information matches the first time period.
In one embodiment, the second processing unit is configured to:
if the first information does not exist in the cache database, acquiring second information matched with the first information from the database and a first time period matched with the second information; storing the first information, the second information and the first time period in the cache database in a matching way; and determining the second information as a response result of the query request.
In one embodiment, the first processing unit is configured to:
Receiving a query request, wherein the query request carries an identifier of a user, a service type, an identifier of an article of the user and a first time;
and acquiring the value of the target attribute of the article based on the identification of the user, the identification of the article of the user and the first time, and combining the identification of the user, the service type and the value of the target attribute of the article into first information.
In one embodiment, the first processing unit is configured to:
querying a summary of an information table from the database, wherein the summary comprises an identification of the user, and the validity period of the summary comprises the first time;
acquiring target attributes from the abstract;
and acquiring the value of the target attribute of the object according to the identification of the object of the user and the target attribute.
In one embodiment, the second processing unit is configured to:
acquiring the identification of the abstract from the abstract;
querying the information table containing the identification of the abstract from a database;
and obtaining information matched with the service type and the value of the object attribute of the article from the information table, and determining the information as second information matched with the first information.
In one embodiment, the second processing unit is configured to:
and determining the intersection of the validity period of the abstract and the service processing time period as the first time period, or directly determining the validity period of the abstract as the first time period.
In one embodiment, the second processing unit is configured to:
and taking the first information as a key, taking the second information and the first time period as values, and storing the second information and the first time period in the cache database in a matching manner in a key value manner.
To achieve the above object, according to still another aspect of an embodiment of the present invention, there is provided an electronic apparatus.
An electronic device according to an embodiment of the present invention includes: one or more processors; and the storage device is used for storing one or more programs, and when the one or more programs are executed by the one or more processors, the one or more processors are enabled to realize the method for inquiring information provided by the embodiment of the invention.
To achieve the above object, according to still another aspect of an embodiment of the present invention, a computer-readable medium is provided.
A computer readable medium of an embodiment of the present invention has stored thereon a computer program which, when executed by a processor, implements a method for querying information provided by the embodiment of the present invention.
One embodiment of the above invention has the following advantages or benefits: the condition of obtaining the response result is changed from determining that the cache database exists and simultaneously contains the first information and the first time information to determining that the cache database exists and the first time period comprises the first time, so that the information amount in the cache database is reduced, the space occupied by the cache database is reduced, the access times of the database are reduced, and the query efficiency is improved.
Further effects of the above-described non-conventional alternatives are described below in connection with the embodiments.
Drawings
The drawings are included to provide a better understanding of the invention and are not to be construed as unduly limiting the invention. Wherein:
FIG. 1 is a schematic diagram of the main flow of a method for querying information according to an embodiment of the invention;
FIG. 2 is a schematic diagram of the main flow of a method of querying information according to another embodiment of the present invention;
FIG. 3 is an application scenario of a method of querying a database according to another embodiment of the present invention;
FIG. 4 is a schematic diagram of the main units of an apparatus for querying information according to an embodiment of the present invention;
FIG. 5 is an exemplary system architecture diagram in which embodiments of the present invention may be applied;
Fig. 6 is a schematic diagram of a computer system suitable for use in implementing an embodiment of the invention.
Detailed Description
Exemplary embodiments of the present invention will now be described with reference to the accompanying drawings, in which various details of the embodiments of the present invention are included to facilitate understanding, and are to be considered merely exemplary. Accordingly, those of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the invention. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
It is noted that embodiments of the invention and features of the embodiments may be combined with each other without conflict.
In the second query, the first information acquired by the first query has the same content as the first part of the information acquired by the second query, but the first information acquired by the first query is totally different from the first information acquired by the second query, so that the first information acquired by the second query does not exist in the cache database, the second information needs to be acquired from the database, and the second information is determined as a response result of the second query. The database needs to be accessed to obtain the response result of the second query, and the problem of the prior art that the database has a large number of access times exists. The database is time consuming to access, and thus the prior art has the problem of inefficient queries.
In order to solve the problems in the prior art, an embodiment of the present invention provides a method for querying information, as shown in fig. 1, the method includes:
step S101, acquiring first information and first time based on a query request.
It should be noted that, the specific embodiments of this step are described in detail below, and are not described herein.
Step S102, if the cache database stores the first information, acquiring second information and a first time period which are stored in a matching way with the first information from the cache database; if the first time period comprises the first time, determining the second information as a response result of the query request; wherein the second information matches the first time period.
In this step, when the first information exists in the cache database, the first information is used as a key, the second information and the first time period are used as values, and the values are matched and stored in the cache database in a key-value mode.
The following describes, as a specific example, that the first period of time includes a first time: the first time period is 2019-12-1 to 2019-12-31, the first time is 2019-12-2, and 2019-12 includes 2019-12-2.
It should be noted that, if the first time period does not include the first time, acquiring third information matched with the first information from the database, and a second time period matched with the third information; and matching and storing the first information, the third information and the second time period in a cache database, and determining the third information as a response result of the query request.
Specifically, the third information may be the same as or different from the second information. The second time period is different from the first time period. The method for obtaining the third information from the database is the same as the method for obtaining the second information from the database, and the method for determining the second time period is the same as the method for determining the first time period, and will not be described again.
In an embodiment of the present invention, the method further includes:
if the first information does not exist in the cache database, acquiring second information matched with the first information from the database and a first time period matched with the second information; storing the first information, the second information and the first time period in the cache database in a matching way; and determining the second information as a response result of the query request.
In this embodiment, it should be noted that the cache database does not have the first information, that is, the cache database does not have a key where the storage object is the first information.
In addition, the second information matched with the first information and the first time period matched with the second information are obtained from the database, and are described in detail below, and are not described in detail herein.
In this embodiment, the first information, the second information and the first time period are stored in the cache database in a matching manner, so that the information can be directly queried from the cache database later, and the query efficiency is further improved.
In an embodiment of the present invention, acquiring first information and first time based on a query request includes:
receiving a query request, wherein the query request carries an identifier of a user, a service type, an identifier of an article of the user and a first time;
and acquiring the value of the target attribute of the article based on the identification of the user, the identification of the article of the user and the first time, and combining the identification of the user, the service type and the value of the target attribute of the article into first information.
In this embodiment, taking the field of logistics as an example, in implementation, the identification of the user may be the name of the user or the user code (the logistics company sets up a number combination for the user, which has uniqueness). The identity of the user's item may be an inventory holding unit (Stock keeping Unit, SKU) of the user's item; the first time may be a service occurrence date. The business types include sales and export, purchasing and warehousing, storage or return and warehousing, etc.
The process of obtaining the value of the target attribute of the item is described in detail below and is not described in detail herein.
In this embodiment, the user's identifier, the service type, and the value of the object attribute of the object are combined into the first information, and the key in the cache database is the first information, and is no longer the first information and the first time, so that the information amount in the cache database is further reduced, and the query efficiency is further improved.
In an embodiment of the present invention, obtaining a value of a target attribute of an item of the user based on an identification of the item, an identification of the item of the user, and the first time includes:
querying a summary of an information table from the database, wherein the summary comprises an identification of the user, and the validity period of the summary comprises the first time;
acquiring target attributes from the abstract;
and acquiring the value of the target attribute of the object according to the identification of the object of the user and the target attribute.
In this embodiment, the database may be a quotation database, and the summary may be a quotation master note, where the summary is stored, when implemented. The summary includes the target attribute, the validity period of the summary, and the identity of the user. The target attribute may be a bid dimension.
It should be appreciated that the bid dimension of one user is fixed. The bid dimension may be an item type and a billing category. The values of the article type include small (e.g., small package), medium (e.g., medium package), and large (e.g., large package), etc. The values of the billing class include apparel class (e.g., women's wear), apparel class (e.g., men's wear), home textile class, electronic and electrical appliance class, and outdoor exercises class, among others. The bid dimension may also be the manner in which the warehouse stores the items. The manner of storing articles in the warehouse comprises normal temperature storage, fresh-keeping storage, temperature-control storage, refrigeration, freezing storage or deep-cooling storage and the like.
And acquiring the value of the target attribute of the object from a basic information base according to the identification of the object of the user and the target attribute. The identity of the user's item, the target attribute, and the value match of the target attribute of the item are stored in a base information repository. Of course, the base information base also matches the values of the stored items 'attributes other than the target attributes, and the items' attributes other than the target attributes. In addition, each article is preset with an article type and a billing classification.
In an embodiment of the present invention, obtaining second information matching the first information from a database includes:
Acquiring the identification of the abstract from the abstract;
querying the information table containing the identification of the abstract from a database;
and obtaining information matched with the service type and the value of the object attribute of the article from the information table, and determining the information as second information matched with the first information.
In this embodiment, the identification of the summary may be a code (the code may be a set of numbers, with uniqueness) of the quotation master; the abstract comprises an identifier of the abstract; the information table may be a quotation schedule; the quotation details table is stored in a database; the quotation details table matches the stored business type, the value of the target attribute of the item, and the second information. In addition, the quotation details table has a one-to-one correspondence with the quotation master list.
The second information includes a price per unit, a unit, an accuracy of the price per unit, a discount, etc. The values of the target attributes of the items are different and the second information is different.
In the embodiment, the second information matched with the service type and the value of the object attribute of the object is obtained from the information table containing the identification of the abstract, and the abstract comprises the identification of the user, so that the accurate second information is obtained, and the accuracy of information inquiry is improved.
In an embodiment of the present invention, the method for determining the first time period includes:
and determining the intersection of the validity period of the abstract and the service processing time period as the first time period, or directly determining the validity period of the abstract as the first time period.
In this embodiment, the service processing period may be determined according to a settlement manner of the user. For example, if the settlement mode of the user is a month, the service processing time period is from the beginning of the month to the end of the month. In addition, the first period of time is stored in advance in the database.
The following describes, as a specific example, why the intersection of the validity period of the digest and the service processing period is determined as the first period. The user has a quotation main bill P003 and a quotation main bill P004, the validity period of the quotation main bill P003 of the user is 2019-11-01 to 2019-11-10, the validity period of the quotation main bill P004 of the user is 2019-11-11 to 2019-11-30, and the service processing time period is 2019-11-01 to 2019-11-30. The fees generated during 2019-11-01 to 2019-11-10 should use the price list corresponding to P003 and the fees generated during 2019-11-11 to 2019-11-30 should use the price list corresponding to P004. Directly determining the traffic processing time period as the first time period may result in the costs incurred during 2019-11-01 to 2019-11-10 using the price list corresponding to P004, ultimately yielding erroneous second information.
In this embodiment, the first period is an intersection of the validity period of the abstract and the service processing period, or the validity period of the abstract, but not the service processing period, so that the possibility of obtaining the wrong second information is reduced, and the accuracy of information query is further improved.
In an embodiment of the present invention, storing the first information, and the second information and the first period of time in the cache database in a matching manner includes:
and taking the first information as a key, taking the second information and the first time period as values, and storing the second information and the first time period in the cache database in a matching manner in a key value manner.
In this embodiment, it should be noted that the second information may be queried from the database, but the second information that is often used is stored in the cache database, so that the query efficiency of the second information may be improved.
In this embodiment, the key includes only the first information, and does not include the first time, so that the dimension of the key is reduced, the number of keys in the cache database is reduced, the information amount in the cache database is further reduced, the space occupying the cache database is further reduced, and the query efficiency is further improved.
In order to solve the problems in the prior art, another embodiment of the present invention provides a method for querying information.
It should be noted that, the logistics company provides the user with the warehouse distribution and value-added services, provides the user with quotations based on the services, and charges the fee according to the quotations. The number of users is large, and the settlement cost according to the present method is very complicated, so that the settlement cost according to the non-present method, such as monthly settlement, is generally adopted. For example, the validity period of the quotation master sheet P001 of the user C is 2019-01-01 to 2019-12-31. 2020-01-01 requires calculation of service charges for user C in the range 2019-12-01 to 2019-12-31. The user has a sales outlet order S001 at 2019-12. The reason for the generation of sales outlet orders: the commodity circulation company stores the article of user C in the warehouse, and user C need to leave the warehouse with the article when selling the article, produces and sells the order of leaving, and commodity circulation company charges to user C.
Sales outlet order S001, service occurrence date: 2019-12-01, value of article piece: small piece, value of billing class: apparel class, user identification: and C, service type: sales out of warehouse (i.e., S), identification of the user' S item: SKU1, bid details are shown in the table below:
TABLE 1 quotation details list
As shown in fig. 2 and 3, the method includes:
step 201, a query request is received, wherein the query request carries an identifier of a user, a service type, an identifier of an article of the user and a first time.
In this step, the user's identification, the type of business, the user's identification of the item, and the first time (i.e., the date of service occurrence) originate from the sales outlet order.
Service occurrence date is the date of field operation, the service system generates field operation and sends the service occurrence date, user code, service type, identification of the user's article and query request to the server applied by the embodiment of the invention. After determining the response result, the server applied in the embodiment of the invention returns the response result to the service system.
Step S202, inquiring a summary of the information table from the database, wherein the summary comprises the identification of a user, and the validity period of the summary comprises the first time.
In this step, the quotation master sheet P001 is queried from the quotation database. The quotation master sheet P001 includes an identification C of the user and a validity period of the quotation master sheet P001, the validity period (2019-01-01 to 2019-12-31) of the quotation master sheet P001 including a first time (2019-12-01).
Step S203, obtaining the target attribute from the abstract.
In this step, the bid dimension of the bid master sheet P001 is the item type and billing classification.
Step S204, obtaining the value of the object attribute of the object from the basic information base according to the identification of the object of the user and the object attribute.
In this step, the values of the target attributes of the item include the value of the item type of the item and the value of the billing class of the item. A code is set for each value of the article part, a code is set for each value of the billing class, for example, a code for the small part is GT001, a code for the clothing class is CT001, and a code for the home textile class is CT002. Whereby when the first information is combined, the value of the article type of the article is replaced with the code of the value of the article type of the article, and the value of the billing class of the article is replaced with the code of the value of the billing class of the article, to reduce the amount of information included in the first information.
Step S205, the user' S identification, the service type, and the value of the object attribute of the item are combined into the first information.
In this step, the user code, the sales outlet, the code of the value of the item piece of the item, and the code of the value of the billing class of the item are combined into first information. The first information is C-S-GT001-CT001.
Step S206, if the first information exists in the cache database, acquiring second information and a first time period which are stored in a matched mode with the first information from the cache database; if the first time period comprises the first time, determining the second information as a response result of the query request; wherein the second information matches the first time period.
Step S207, if the first information does not exist in the cache database, acquiring second information matched with the first information from the database and a first time period matched with the second information; storing the first information, the second information and the first time period in a cache database in a matching way; and determining the second information as a response result of the query request.
In this step, the intersection of the validity period of the digest and the traffic processing period is determined as a first period. For example, the validity period of the quotation master policy P001 is 2019-01-01 to 2019-12-31, the service processing time period is 2019-12-01 to 2019-12-31, and thus, the first time period is 2019-12-01 to 2019-12-31.
Obtaining second information matching the first information from the database, comprising: acquiring the identification of the abstract from the abstract; inquiring an information table containing the identification of the abstract from the database; information matching the service type and the value of the object attribute of the article is obtained from the information table, and is determined as second information matching the first information. Specifically, the quotation details table (i.e., the information table) stores the sales outlet, the value of the article piece of the article, the value of the billing class of the article, and the second information in a matching manner.
After determining the response result, the business system calculates a cost of selling the stock order according to the second information. For example, it is determined that the second information includes 2 elements/piece, and the discount is 0.8. And the number of items in the sales order is 3, then cost = 4.8 element = 3 element x 2 element/element x 0.8.
It should be noted that, if the fee calculation of all orders of the user C is completed, the first information of C included in the cache database and all the information stored in the cache database in a matching manner with the first information are deleted. Thus, the query efficiency of other users can be improved.
It should be understood that the embodiment of the present invention is not only applicable to querying the second information in the fee calculation, but also applicable to other scenarios using the cache database. The selection of keys in the cache database needs to be determined according to specific business scenarios. In an embodiment of the present invention, the same user has a sales order for item A at 2019-12-01, a sales order for item A at 2019-12-02 to 2019-12-31, and other items having the same value as the target attribute of item A are more likely to be sales orders. Thus, the key may not include time. The billing classification does not have the regularity, that is, sales and sales orders of GT001 items are not predicted, or the probability of occurrence of sales and sales orders of GT002 items is low, so the key includes the billing classification.
It should be noted that, the corresponding quotation details table under the quotation master order P001 may be stored in the cache database at a time. Thus, if the first information includes GT001 and CT002, then 3 elements/piece and discount is 0.8 is determined as the response result of the query request, and if the first information includes GT002 and CT003, 4 elements/piece and discount is 0.8 is determined as the response result of the query request. However, the following problems exist: the value of the cache database is overlarge, and the access performance of the cache database is reduced; the information utilization rate in the cache database is not high.
The inventor finds that repeated information is often present for orders of the same user. For example, at 2019-12-01 there is a sales order for item A, and other dates may have sales orders for item A. The logistics company and the service signed by the user have a valid period, and therefore, the sale and delivery order of the article A is fixed in the valid period.
And the whole month order is processed by taking the user as a unit. The cost calculation for all orders for the same user is done in a short time, typically between a few minutes and a few hours. Thus, the rule of the query fee calculation (i.e., the second information) should also be completed in a short time.
Thus, in the embodiment of the present invention, in the case that the first query is completed, the key (i.e., the key) includes only the first information, and does not include the first time of the first query, and the first time period and the second information are simultaneously used as values (i.e., values) and are stored in the cache database in a matching manner in a key-value manner. And in the second inquiry, if the first information is unchanged and the first time of the second inquiry is included in the first time period, directly taking the second information as a response result of the second inquiry. Therefore, the query efficiency is improved and the access times of the database are reduced in a cache database preheating mode.
Caching a database: the data is placed in a database which is directly operated in the memory. Compared with a magnetic disk, the data reading and writing speed of the memory is higher by several orders of magnitude, and compared with the access from the magnetic disk, the data can be stored in the memory, so that the application performance can be greatly improved. The storage mode is generally in a key-value form, and the value can be obtained according to the key during inquiry.
Cache database warm-up: unused data is saved to a cache database to improve query performance.
In order to solve the problems in the prior art, an embodiment of the present invention provides an apparatus for querying information, as shown in fig. 4, the apparatus includes:
a first processing unit 401, configured to obtain first information and a first time based on the query request;
a second processing unit 402, configured to obtain, if a cache database stores the first information, second information and a first period of time, which are stored in a matching manner with the first information, from the cache database; if the first time period comprises the first time, determining the second information as a response result of the query request; wherein the second information matches the first time period.
In an embodiment of the present invention, the second processing unit 402 is configured to:
If the first information does not exist in the cache database, acquiring second information matched with the first information from the database and a first time period matched with the second information; storing the first information, the second information and the first time period in the cache database in a matching way; and determining the second information as a response result of the query request.
In the embodiment of the present invention, the first processing unit 401 is configured to:
receiving a query request, wherein the query request carries an identifier of a user, a service type, an identifier of an article of the user and a first time;
and acquiring the value of the target attribute of the article based on the identification of the user, the identification of the article of the user and the first time, and combining the identification of the user, the service type and the value of the target attribute of the article into first information.
In the embodiment of the present invention, the first processing unit 401 is configured to:
querying a summary of an information table from the database, wherein the summary comprises an identification of the user, and the validity period of the summary comprises the first time;
acquiring target attributes from the abstract;
and acquiring the value of the target attribute of the object according to the identification of the object of the user and the target attribute.
In an embodiment of the present invention, the second processing unit 402 is configured to:
acquiring the identification of the abstract from the abstract;
querying the information table containing the identification of the abstract from a database;
and obtaining information matched with the service type and the value of the object attribute of the article from the information table, and determining the information as second information matched with the first information.
In an embodiment of the present invention, the second processing unit 402 is configured to:
and determining the intersection of the validity period of the abstract and the service processing time period as the first time period, or directly determining the validity period of the abstract as the first time period.
In an embodiment of the present invention, the second processing unit 402 is configured to:
and taking the first information as a key, taking the second information and the first time period as values, and storing the second information and the first time period in the cache database in a matching manner in a key value manner.
It should be understood that the functions performed by each component of the information query device provided in the embodiment of the present invention are described in detail in the information query method in the foregoing embodiment, and are not described herein again.
Fig. 5 illustrates an exemplary system architecture 500 of a method of querying information or an apparatus of querying information to which embodiments of the present invention may be applied.
As shown in fig. 5, the system architecture 500 may include terminal devices 501, 502, 503, a network 504, and a server 505. The network 504 is used as a medium to provide communication links between the terminal devices 501, 502, 503 and the server 505. The network 504 may include various connection types, such as wired, wireless communication links, or fiber optic cables, among others.
A user may interact with the server 505 via the network 504 using the terminal devices 501, 502, 503 to receive or send messages or the like. Various communication client applications may be installed on the terminal devices 501, 502, 503, such as shopping class applications, web browser applications, search class applications, instant messaging tools, mailbox clients, social platform software, etc. (by way of example only).
The terminal devices 501, 502, 503 may be a variety of electronic devices having a display screen and supporting web browsing, including but not limited to smartphones, tablets, laptop and desktop computers, and the like.
The server 505 may be a server providing various services, such as a background management server (by way of example only) providing support for shopping-type websites browsed by users using the terminal devices 501, 502, 503. The background management server may analyze and process the received data such as the product information query request, and feedback the processing result (e.g., the target push information, the product information—only an example) to the terminal device.
It should be noted that, the method for querying information provided by the embodiment of the present invention is generally executed by the server 505, and accordingly, the device for querying information is generally disposed in the server 505.
It should be understood that the number of terminal devices, networks and servers in fig. 5 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
Referring now to FIG. 6, there is illustrated a schematic diagram of a computer system 600 suitable for use in implementing an embodiment of the present invention. The terminal device shown in fig. 6 is only an example, and should not impose any limitation on the functions and the scope of use of the embodiment of the present invention.
As shown in fig. 6, the computer system 600 includes a Central Processing Unit (CPU) 601, which can perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM) 602 or a program loaded from a storage section 608 into a Random Access Memory (RAM) 603. In the RAM 603, various programs and data required for the operation of the system 600 are also stored. The CPU 601, ROM 602, and RAM 603 are connected to each other through a bus 604. An input/output (I/O) interface 605 is also connected to bus 604.
The following components are connected to the I/O interface 605: an input portion 606 including a keyboard, mouse, etc.; an output portion 607 including a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, a speaker, and the like; a storage section 608 including a hard disk and the like; and a communication section 609 including a network interface card such as a LAN card, a modem, or the like. The communication section 609 performs communication processing via a network such as the internet. The drive 610 is also connected to the I/O interface 605 as needed. Removable media 611 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is installed as needed on drive 610 so that a computer program read therefrom is installed as needed into storage section 608.
In particular, according to embodiments of the present disclosure, the processes described above with reference to flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method shown in the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network through the communication portion 609, and/or installed from the removable medium 611. The above-described functions defined in the system of the present invention are performed when the computer program is executed by a Central Processing Unit (CPU) 601.
The computer readable medium shown in the present invention may be a computer readable signal medium or a computer readable storage medium, or any combination of the two. The computer readable storage medium can be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or a combination of any of the foregoing. More specific examples of the computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the context of this document, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In the present invention, however, the computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, with the computer-readable program code embodied therein. Such a propagated data signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination of the foregoing. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, fiber optic cable, RF, etc., or any suitable combination of the foregoing.
The flowcharts and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagrams may represent a unit, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams or flowchart illustration, and combinations of blocks in the block diagrams or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The units involved in the embodiments of the present invention may be implemented in software or in hardware. The described units may also be provided in a processor, for example, described as: a processor includes a first processing unit and a second processing unit. Where the names of the units do not constitute a limitation of the unit itself in some cases, for example, the first processing unit may also be described as "a unit that obtains the first information and the first time based on the query request".
As another aspect, the present invention also provides a computer-readable medium that may be contained in the apparatus described in the above embodiments; or may be present alone without being fitted into the device. The computer readable medium carries one or more programs which, when executed by a device, cause the device to include: acquiring first information and first time based on a query request; if the cache database stores the first information, acquiring second information and a first time period which are stored in a matching way with the first information from the cache database; if the first time period comprises the first time, determining the second information as a response result of the query request; wherein the second information matches the first time period.
According to the technical scheme of the embodiment of the invention, the condition of obtaining the response result is changed from the condition that the cache database is determined to exist and contains the first information and the first time information to the condition that the cache database is determined to exist and the first time period comprises the first time, so that the information amount in the cache database is reduced, the space occupied by the cache database is reduced, the access times of the database are reduced, and the query efficiency is improved.
The above embodiments do not limit the scope of the present invention. It will be apparent to those skilled in the art that various modifications, combinations, sub-combinations and alternatives can occur depending upon design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the scope of the present invention.

Claims (9)

1. A method of querying information, comprising:
acquiring first information and first time based on a query request;
if the cache database stores the first information, acquiring second information and a first time period which are stored in a matching way with the first information from the cache database; if the first time period comprises the first time, determining the second information as a response result of the query request; wherein the second information matches the first time period;
if the first information does not exist in the cache database, acquiring second information matched with the first information from the database and a first time period matched with the second information; storing the first information, the second information and the first time period in the cache database in a matching way; and determining the second information as a response result of the query request.
2. The method of claim 1, wherein obtaining the first information and the first time based on the query request comprises:
receiving a query request, wherein the query request carries an identifier of a user, a service type, an identifier of an article of the user and a first time;
and acquiring the value of the target attribute of the article based on the identification of the user, the identification of the article of the user and the first time, and combining the identification of the user, the service type and the value of the target attribute of the article into first information.
3. The method of claim 2, wherein obtaining the value of the target attribute of the item based on the identification of the user, the identification of the item of the user, and the first time comprises:
querying a summary of an information table from the database, wherein the summary comprises an identification of the user, and the validity period of the summary comprises the first time;
acquiring target attributes from the abstract;
and acquiring the value of the target attribute of the object according to the identification of the object of the user and the target attribute.
4. A method according to claim 3, wherein retrieving from a database second information matching the first information comprises:
Acquiring the identification of the abstract from the abstract;
querying the information table containing the identification of the abstract from a database;
and obtaining information matched with the service type and the value of the object attribute of the article from the information table, and determining the information as second information matched with the first information.
5. The method of claim 4, wherein the determining of the first time period comprises:
and determining the intersection of the validity period of the abstract and the service processing time period as the first time period, or directly determining the validity period of the abstract as the first time period.
6. The method of claim 1, wherein storing the first information, and the second information and the first time period matches in the cache database, comprises:
and taking the first information as a key, taking the second information and the first time period as values, and storing the second information and the first time period in the cache database in a matching manner in a key value manner.
7. An apparatus for querying information, comprising:
the first processing unit is used for acquiring first information and first time based on the query request;
The second processing unit is used for acquiring second information and a first time period which are stored in a matching way with the first information from the cache database if the cache database stores the first information; if the first time period comprises the first time, determining the second information as a response result of the query request; wherein the second information matches the first time period;
the second processing unit is used for: if the first information does not exist in the cache database, acquiring second information matched with the first information from the database and a first time period matched with the second information; storing the first information, the second information and the first time period in the cache database in a matching way; and determining the second information as a response result of the query request.
8. An electronic device, comprising:
one or more processors;
storage means for storing one or more programs,
when executed by the one or more processors, causes the one or more processors to implement the method of any of claims 1-6.
9. A computer readable medium, on which a computer program is stored, characterized in that the program, when being executed by a processor, implements the method according to any of claims 1-6.
CN202010295677.8A 2020-04-15 2020-04-15 Method and device for inquiring information Active CN113535769B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010295677.8A CN113535769B (en) 2020-04-15 2020-04-15 Method and device for inquiring information

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010295677.8A CN113535769B (en) 2020-04-15 2020-04-15 Method and device for inquiring information

Publications (2)

Publication Number Publication Date
CN113535769A CN113535769A (en) 2021-10-22
CN113535769B true CN113535769B (en) 2023-11-03

Family

ID=78120097

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010295677.8A Active CN113535769B (en) 2020-04-15 2020-04-15 Method and device for inquiring information

Country Status (1)

Country Link
CN (1) CN113535769B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115063923A (en) * 2022-06-28 2022-09-16 北京字跳网络技术有限公司 Voting processing method, system, device, electronic equipment and storage medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104572727A (en) * 2013-10-22 2015-04-29 阿里巴巴集团控股有限公司 Data querying method and device
CN108984553A (en) * 2017-06-01 2018-12-11 北京京东尚科信息技术有限公司 Caching method and device
WO2019154353A1 (en) * 2018-02-07 2019-08-15 中兴通讯股份有限公司 System running parameter query method, matching method and apparatus, and node device
WO2019210585A1 (en) * 2018-05-03 2019-11-07 平安科技(深圳)有限公司 Message push method and apparatus, and computer readable storage medium and terminal device

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104572727A (en) * 2013-10-22 2015-04-29 阿里巴巴集团控股有限公司 Data querying method and device
CN108984553A (en) * 2017-06-01 2018-12-11 北京京东尚科信息技术有限公司 Caching method and device
WO2019154353A1 (en) * 2018-02-07 2019-08-15 中兴通讯股份有限公司 System running parameter query method, matching method and apparatus, and node device
WO2019210585A1 (en) * 2018-05-03 2019-11-07 平安科技(深圳)有限公司 Message push method and apparatus, and computer readable storage medium and terminal device

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
基于JDBC数据管理与查询优化的研究;韩兵;李晶晶;方英兰;;计算机技术与发展(第09期);全文 *

Also Published As

Publication number Publication date
CN113535769A (en) 2021-10-22

Similar Documents

Publication Publication Date Title
CN107172151B (en) Method and device for pushing information
CN107967284B (en) Method and device for storing and inquiring order information
CN107229718B (en) Method and device for processing report data
CN112884405A (en) Inquiry system and scheduling method thereof
CN110473036B (en) Method and device for generating order number
CN113095893A (en) Method and device for determining sales of articles
CN113535769B (en) Method and device for inquiring information
CN112182138A (en) Catalog making method and device
CN113762863B (en) Inventory management method and device
CN113761565A (en) Data desensitization method and apparatus
US20140244484A1 (en) Network computing environment collection and notification of point of sale information
CN113112048A (en) Method and device for returning articles to warehouse
CN115760300A (en) Method and system for managing sales products based on labels
CN110956514A (en) Method and device for generating order information
CN107239962B (en) Method and system for matching multi-dimensional data units in electronic information system
CN113868687A (en) Task processing progress management method and device
CN113762865A (en) Inventory information processing method and device
CN113496386A (en) Method and device for combined charging
CN110738806B (en) Payment mode determination method, device and system and electronic equipment
CN113822516A (en) Matching method and device for distribution and transportation side
CN113762835A (en) Method and device for processing order data
CN108733668B (en) Method and device for querying data
CN113780921B (en) Price inquiry processing method and device
CN112651536A (en) Method and device for determining delivery address
CN113761077B (en) Method and device for processing bill task

Legal Events

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