CN113535769A - Method and device for inquiring information - Google Patents

Method and device for inquiring information Download PDF

Info

Publication number
CN113535769A
CN113535769A CN202010295677.8A CN202010295677A CN113535769A CN 113535769 A CN113535769 A CN 113535769A CN 202010295677 A CN202010295677 A CN 202010295677A CN 113535769 A CN113535769 A CN 113535769A
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.)
Granted
Application number
CN202010295677.8A
Other languages
Chinese (zh)
Other versions
CN113535769B (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

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
    • 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: acquiring first information and first time based on the query request; if the cache database is stored in the first information, second information and a first time period which are stored in a matching mode with the first information are obtained 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. The implementation mode reduces the information amount in the cache database, reduces the space occupied by the cache database, reduces the access times of the database and improves the query efficiency.

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 process for inquiring information comprises the following steps: acquiring information I based on the query request; and if the cache database stores the first information, acquiring second information matched and stored with the first information from the cache database, and determining the second information as a response result.
In the process of implementing the invention, the inventor finds that at least the following problems exist in the prior art:
if the information I obtained by the first query is the same as part of the content of the information I obtained by the second query in the two queries, the cache database stores two pieces of the same information II, so that the problems of large information amount 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 database access times and low query efficiency exist.
Disclosure of Invention
In view of this, embodiments of the present invention provide a method and an apparatus for querying information, which can reduce the amount of information in a cache database, reduce the space occupied by the cache database, reduce the number of times of accessing the database, and improve the querying efficiency.
To achieve the above object, according to an aspect of an embodiment of the present invention, there is provided a method of querying information.
The method for inquiring information of the embodiment of the invention comprises the following steps:
acquiring first information and first time based on the query request;
if the cache database is stored in the first information, second information and a first time period which are stored in a matching mode with the first information are obtained 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, second information matched with the first information and a first time period matched with the second information are obtained from the database; storing the first information, the second information and the first time period in a cache database in a matching manner; and determining the second information as a response result of the query request.
In one embodiment, obtaining the first information and the first time based on the 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 a 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 for a 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, the summary including an identification of the user, a validity period of the summary including the first time;
acquiring a target attribute from the abstract;
and acquiring the value of the target attribute of the item according to the identification of the item of the user and the target attribute.
In one embodiment, obtaining second information from a database that matches the first information comprises:
acquiring the identifier of the abstract from the abstract;
querying the information table containing the identification of the abstract from a database;
and obtaining information matched with both the service type and the value of the target 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 a 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 matching and storing the first information as a key, the second information and the first time period as values in the cache database in a key value mode.
To achieve the above object, according to another aspect of the embodiments of the present invention, there is provided an apparatus for querying information.
The device for inquiring information of the embodiment of the invention comprises:
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 matched with the first information and stored 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 to:
if the first information does not exist in the cache database, second information matched with the first information and a first time period matched with the second information are obtained from the database; storing the first information, the second information and the first time period in a cache database in a matching manner; and determining the second information as a response result of the query request.
In one embodiment, the first processing unit is 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 a 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 to:
querying a summary of an information table from the database, the summary including an identification of the user, a validity period of the summary including the first time;
acquiring a target attribute from the abstract;
and acquiring the value of the target attribute of the item according to the identification of the item of the user and the target attribute.
In one embodiment, the second processing unit is to:
acquiring the identifier of the abstract from the abstract;
querying the information table containing the identification of the abstract from a database;
and obtaining information matched with both the service type and the value of the target 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 to:
and determining the intersection of the validity period of the abstract and a 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 to:
and matching and storing the first information as a key, the second information and the first time period as values in the cache database in a key value mode.
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 of an embodiment of the present invention includes: one or more processors; 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 implement the method for querying the 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, there is provided a computer-readable medium.
A computer-readable medium of an embodiment of the present invention stores thereon a computer program, and the computer program, when executed by a processor, implements the method for querying information provided by an embodiment of the present invention.
One embodiment of the above invention has the following advantages or benefits: and converting the condition of obtaining the response result from the condition that the cache database contains the first information and the first time information at the same time into the condition that the first information exists in the cache database, wherein the first time 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-mentioned non-conventional alternatives will be described below in connection with the embodiments.
Drawings
The drawings are included to provide a better understanding of the invention and are not to be construed as unduly limiting the invention. Wherein:
FIG. 1 is a schematic diagram of a main flow of a method of querying information according to an embodiment of the invention;
FIG. 2 is a schematic diagram of a 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 elements 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 employed;
fig. 6 is a schematic block diagram of a computer system suitable for use in implementing a terminal device or server of an embodiment of the invention.
Detailed Description
Exemplary embodiments of the present invention are described below with reference to the accompanying drawings, in which various details of embodiments of the invention are included to assist understanding, and which are to be considered as 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 should be noted that the embodiments and features of the embodiments may be combined with each other without conflict.
During the second query, part of the content of the first information obtained by the first query is the same as that of the first information obtained by the second query, but the first information obtained by the first query is different from that obtained by the second query as a whole, so that the first information obtained by the second query does not exist in the cache database, and the second information needs to be obtained from the database and is determined as the 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 large database access times exists in the prior art. The access to the database is time-consuming, and thus, the prior art has a problem of low query efficiency.
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 the query request.
It should be noted that the specific implementation of this step is described in detail below, and is not described herein again.
Step S102, if the cache database is stored in the first information, second information and a first time period which are matched with the first information and stored are obtained 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, in a specific implementation, if the first information exists in the cache database, the first information is used as a key, and the second information and the first time period are used as values, and are stored in the cache database in a key value matching manner.
The following describes a specific example of the first time period including the first time: the first time period is 2019-12-1 to 2019-12-31, the first time period is 2019-12-2, and 2019-12 includes 2019-12-2.
If the first time period does not include the first time, obtaining third information matched with the first information from the database, and obtaining 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 acquiring the third information from the database is the same as the method for acquiring 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, which is not repeated herein.
In the embodiment of the present invention, the method further includes:
if the first information does not exist in the cache database, second information matched with the first information and a first time period matched with the second information are obtained from the database; storing the first information, the second information and the first time period in a cache database in a matching manner; 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 of which the storage object is the first information.
In addition, second information matched with the first information and a first time period matched with the second information are acquired from a database, which are described in detail below and are not described herein again.
In the embodiment, the first information, the second information and the first time period are matched and stored in the cache database, so that the information can be directly inquired from the cache database later, and the inquiry efficiency is further improved.
In the embodiment of the present invention, acquiring the first information and the first time based on the 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 a 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 logistics field as an example, in a specific implementation, the identification of the user may be a name or a user code of the user (a combination of numbers set by the logistics company for the user has uniqueness). The identification of the user's item may be a Stock Keeping Unit (SKU) of the user's item; the first time may be a service occurrence date. The business types comprise selling, warehousing, storing or returning and warehousing and the like.
The process of obtaining the value of the target property of the item is described in detail below and will not be described further herein.
In the embodiment, the user identification, the service type and the value of the object attribute of the article are combined into the first information, and the key in the cache database is the first information and is not 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 the value of the target attribute of the item based on the identifier of the user, the identifier of the item of the user, and the first time includes:
querying a summary of an information table from the database, the summary including an identification of the user, a validity period of the summary including the first time;
acquiring a target attribute from the abstract;
and acquiring the value of the target attribute of the item according to the identification of the item of the user and the target attribute.
In this embodiment, the database may be a quotation database, the summary may be a quotation master, and the summary is stored in the database. The abstract comprises target attributes, the validity period of the abstract and the identification of the user. The target attribute may be an offer dimension.
It should be understood that the price quote dimension for a user is fixed. The offer dimension may be item type and billing classification. The values of the article type include small (e.g., small pack), medium (e.g., medium pack), large (e.g., large pack), and the like. The value of the billing class includes a first class of apparel (e.g., women's dress), a second class of apparel (e.g., men's dress), a home textile class, an electronic appliance class, an outdoor sports class, and the like. The quote dimension may also be the way in which the warehouse stores the items. The storage mode of the warehouse comprises normal temperature storage, fresh storage, temperature control storage, refrigeration, freezing storage or deep cooling storage and the like.
And acquiring the value of the target attribute of the item from a basic information base according to the identification of the item of the user and the target attribute. The identification of the user's item, the target attribute, and the value of the item's target attribute are stored in the base information repository in a matching manner. Of course, the basic information base also stores the attributes of the article other than the target attribute in a matching manner, and the values of the attributes of the article other than the target attribute. In addition, each article is preset with an article type and a charging classification.
In the embodiment of the present invention, acquiring the second information matched with the first information from the database includes:
acquiring the identifier of the abstract from the abstract;
querying the information table containing the identification of the abstract from a database;
and obtaining information matched with both the service type and the value of the target 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 an encoding of the quotation master (the encoding may be a set of numbers, having uniqueness); the abstract comprises an identification of the abstract; the information table may be a quotation list; storing the quotation list in a database; and the quotation list is matched with the storage service type, the value of the target attribute of the article and the second information. In addition, the quotation list and the quotation main list have one-to-one correspondence.
The second information includes price per unit, accuracy and discount of price per unit, etc. The object attribute of the object has a different value and the second information is different.
In the embodiment, the second information matched with the service type and the value of the target attribute of the article is obtained from the information table containing the identifier of the abstract, and the abstract comprises the identifier of the user, so that the accurate second information is obtained, and the accuracy of information query 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 a 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 time period may be determined according to a settlement manner of the user. For example, if the settlement mode of the user is monthly, 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 pre-stored in a database.
The following explains why the intersection of the validity period of the summary and the business process time period is determined as the first time period by a specific example. The user has a quotation main note P003 and a quotation main note P004, the validity period of the quotation main note P003 of the user is 2019-11-01 to 2019-11-10, the validity period of the quotation main note 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 expenses generated in the period from 2019-11-01 to 2019-11-10 should use the quotation list corresponding to P003, and the expenses generated in the period from 2019-11-11 to 2019-11-30 should use the quotation list corresponding to P004. Directly determining the service processing time period as the first time period may cause the charges generated during the periods 2019-11-01 to 2019-11-10 to use the quotation list corresponding to the P004, and finally obtain wrong second information.
In this embodiment, the first time period is an intersection of the validity period of the summary and the service processing time period, or the validity period of the summary, but not the service processing time period, so that the possibility of obtaining the wrong second information is reduced, and the accuracy of information query is further improved.
In this embodiment of the present invention, matching and storing the first information, the second information, and the first time period in the cache database includes:
and matching and storing the first information as a key, the second information and the first time period as values in the cache database in a key value mode.
In this embodiment, it should be noted that the second information may be queried from the database, but the efficiency of querying the second information may be improved by storing the frequently used second information in the cache database.
In this embodiment, the key includes only the first information, and does not include the first time, the dimensionality of the key is reduced, the number of keys in the cache database is reduced, the amount of information in the cache database is further reduced, the space occupied by 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 warehousing and transportation and value-added services for the users, provides quotes to the users based on the services, and charges the fees according to the quotes. The number of users is huge, and the settlement of the fee in a current settlement mode is very complicated, so that the settlement of the fee in a non-current settlement mode, such as monthly settlement, is generally adopted. For example, the validity period of the user C's bid master P001 is 2019-01-01 to 2019-12-31. 2020-01-01 requires calculating the service cost of user C in the range of 2019-12-01 to 2019-12-31. The user has a sale shipment order S001 at 2019-12. Reason for generation of sales shipment order: the logistics company stores the items of the user C in the warehouse, the user C needs to take the items out of the warehouse when selling the items, a selling and ex-warehouse order is generated, and the logistics company charges the user C.
Sales shipment order S001, service occurrence date: 2019-12-01, item type value: small, value of billing classification: clothing class, user identification: c, service type: sales export (i.e., S), identification of the user' S item: SKU1, quote list is shown in the following table:
Figure BDA0002452099630000111
TABLE 1 quotation statement
As shown in fig. 2 and 3, the method includes:
step S201, receiving a query request, wherein the query request carries the identification of the user, the service type, the identification of the user' S article and the first time.
In this step, the user's identification, the type of business, the user's item identification, and the first time (i.e., the date the service occurred) are derived from the sales outbound order.
The service occurrence date is the date of the field operation, the service system generates the field operation, and the service occurrence date, the user code, the service type, the identification of the user article and the query request are sent to the server applied to the embodiment of the invention. After the server applied in the embodiment of the invention determines the response result, the server returns the response result to the service system.
Step S202, inquiring the abstract of the information table from the database, wherein the abstract comprises the identification of the user, and the validity period of the abstract comprises the first time.
In this step, a quotation master P001 is queried from the quotation database. The quotation main note P001 comprises the identification C of the user and the validity period of the quotation main note P001, and the validity period (2019-01-01 to 2019-12-31) of the quotation main note P001 comprises the first time (2019-12-01).
And step S203, acquiring the target attribute from the abstract.
In this step, the quote dimension of the quote master P001 is the item type and billing classification.
And step S204, acquiring the value of the target attribute of the article from the basic information base according to the identification and the target attribute of the article of the user.
In this step, the value of the target attribute of the item includes a value of an item part type of the item and a value of a billing class of the item. A code is set for each value of the article type, and a code is set for each value of the billing classification, for example, a code of a small article is GT001, a code of a dress type is CT001, and a code of a home textile type is CT 002. Thereby, when the first information is combined, the value of the item type of the item is replaced with the code of the value of the item type of the item, and the value of the billing classification of the item is replaced with the code of the value of the billing classification of the item, so as to reduce the amount of information included in the first information.
Step S205, combining the user identification, the service type and the value of the object attribute of the article into first information.
In this step, the user code, the sales shipment, the code of the value of the item part type of the item, and the code of the value of the billing classification of the item are combined into the first information. The first information is C-S-GT001-CT 001.
Step S206, if the first information exists in the cache database, second information and a first time period which are matched with the first information and stored are obtained 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, second information matched with the first information and a first time period matched with the second information are obtained from the database; 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 summary and the business process time period is determined as the first time period. For example, the validity period of the quotation main bill 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 matched with the first information from a database, wherein the second information comprises: acquiring an identifier of the abstract from the abstract; inquiring an information table containing the identification of the abstract from a database; and obtaining information matched with both the service type and the value of the target attribute of the article from the information table, and determining the information as second information matched with the first information. Specifically, the offer list (i.e., the information table) stores therein the sales shipment, the value of the item type of the item, the value of the billing classification of the item, and the second information in a matching manner.
After determining the response result, the business system calculates the cost of selling the outbound order according to the second information. For example, it is determined that the second information includes 2 elements/element, and the discount is 0.8. And the number of the goods in the selling order is 3, the cost is 4.8 yuan, 3 yuan × 2 yuan/0.8 yuan.
It should be noted that, if the calculation of the cost of all the orders of the user C is completed, the first information including C in the cache database and all the information stored in match with the first information are deleted. Therefore, 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 service scenarios. In the embodiment of the invention, the same user has a selling outbound order of the item A in 2019-12-01, a selling outbound order of the item A in 2019-12-02 to 2019-12-31 and a selling outbound order of other items with the same value of the target attribute of the item A. Thus, a key may not include a time. The charging classification does not have the regularity, that is, the selling outbound order of GT001 type articles cannot be predicted, or the occurrence probability is low, so the key includes the charging classification.
It should be noted that, the corresponding quotation list under the quotation master P001 may be stored in the cache database at one time. Thus, in the case where the first information includes GT001 and CT002, 3-element and discount of 0.8 are determined as the response result of the query request, and in the case where the first information includes GT002 and CT003, 4-element and discount of 0.8 are determined as the response result of the query request. However, the following problems exist: the access performance of the cache database is reduced due to the overlarge value of the cache database; the utilization of information in the cache database is not high.
The inventor finds orders of the same user, and there is often duplicate information. For example, there is a sales shipment order for item A at 2019-12-01, and sales shipment orders for item A may also appear on other dates. The service contract between the logistics company and the user has a valid period, so that the cost of the sales delivery order of the article A is fixed in the valid period.
The order of the whole month is processed by taking the user as a unit. The calculation of the cost of all orders of 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 shorter time.
Therefore, in the embodiment of the present invention, in the case that the first query is completed, the key (i.e. 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 both used as values (i.e. values) and are stored in the cache database in a matching manner by means of the key. And in the second query, if the first information is unchanged and the first time of the second query is included in the first time period, directly taking the second information as a response result of the second query. Therefore, the query efficiency is improved and the access times of the database are reduced in a mode of preheating the cache database.
Caching a database: and (4) putting the data into a database which is directly operated in the memory. Compared with a magnetic disk, the data read-write speed of the memory is higher by several orders of magnitude, and the application performance can be greatly improved by storing data in the memory compared with accessing from the magnetic disk. The storage mode is generally in a key-value form, and values can be obtained according to keys during query.
Preheating a cache database: and saving unused data to a cache database to improve the query performance.
In order to solve the problems in the prior art, an embodiment of the present invention provides an apparatus for querying information, where 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, if a cache database stores the first information, obtain, from the cache database, second information and a first time period that are stored in a matching manner with 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 this embodiment of the present invention, the second processing unit 402 is configured to:
if the first information does not exist in the cache database, second information matched with the first information and a first time period matched with the second information are obtained from the database; storing the first information, the second information and the first time period in a cache database in a matching manner; and determining the second information as a response result of the query request.
In this 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 a 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 of the present invention, the first processing unit 401 is configured to:
querying a summary of an information table from the database, the summary including an identification of the user, a validity period of the summary including the first time;
acquiring a target attribute from the abstract;
and acquiring the value of the target attribute of the item according to the identification of the item of the user and the target attribute.
In this embodiment of the present invention, the second processing unit 402 is configured to:
acquiring the identifier of the abstract from the abstract;
querying the information table containing the identification of the abstract from a database;
and obtaining information matched with both the service type and the value of the target attribute of the article from the information table, and determining the information as second information matched with the first information.
In this 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 a 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 of the present invention, the second processing unit 402 is configured to:
and matching and storing the first information as a key, the second information and the first time period as values in the cache database in a key value mode.
It should be understood that the functions performed by each component of the apparatus for querying information according to the embodiments of the present invention have been described in detail in the method for querying information according to the above embodiments, and are not described herein again.
Fig. 5 shows an exemplary system architecture 500 to which the method of querying information or the apparatus of querying information of the 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 serves to provide a medium for communication links between the terminal devices 501, 502, 503 and the server 505. Network 504 may include various connection types, such as wired, wireless communication links, or fiber optic cables, to name a few.
The user may use the terminal devices 501, 502, 503 to interact with a server 505 over a network 504 to receive or send messages or the like. The terminal devices 501, 502, 503 may have installed thereon various communication client applications, such as shopping-like applications, web browser applications, search-like applications, instant messaging tools, mailbox clients, social platform software, etc. (by way of example only).
The terminal devices 501, 502, 503 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop portable computers, desktop computers, and the like.
The server 505 may be a server providing various services, such as a background management server (for example only) providing support for shopping websites browsed by users using the terminal devices 501, 502, 503. The backend management server may analyze and perform other processing on the received data such as the product information query request, and feed back a processing result (for example, target push information, product information — just 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 apparatus 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, a block diagram of a computer system 600 suitable for use with a terminal device implementing an embodiment of the invention is shown. The terminal device shown in fig. 6 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present invention.
As shown in fig. 6, the computer system 600 includes a Central Processing Unit (CPU)601 that 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 necessary for the operation of the system 600 are also stored. The CPU 601, ROM 602, and RAM 603 are connected to each other via 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, a mouse, and the like; an output portion 607 including a display such as a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, and a speaker; 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 driver 610 is also connected to the I/O interface 605 as needed. A removable medium 611 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 610 as necessary, so that a computer program read out therefrom is mounted in the storage section 608 as necessary.
In particular, according to the embodiments of the present disclosure, the processes described above with reference to the 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 illustrated in the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network through the communication section 609, and/or installed from the removable medium 611. The computer program performs the above-described functions defined in the system of the present invention when executed by the Central Processing Unit (CPU) 601.
It should be noted that the computer readable medium shown in the present invention can be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination 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 present invention, 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, a computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. 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 flowchart 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 described in the embodiments of the present invention may be implemented by software or hardware. The described units may also be provided in a processor, and may be described as: a processor includes a first processing unit and a second processing unit. Where the names of the units do not in some cases constitute a limitation on the units themselves, 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 separate and not incorporated into the device. The computer readable medium carries one or more programs which, when executed by a device, cause the device to comprise: acquiring first information and first time based on the query request; if the cache database is stored in the first information, second information and a first time period which are stored in a matching mode with the first information are obtained 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 converted from the condition that the cache database is determined to contain the first information and the first time information at the same time, and the first time 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 frequency of the database is reduced, and the query efficiency is improved.
The above-described embodiments should not be construed as limiting the scope of the invention. Those skilled in the art will appreciate that various modifications, combinations, sub-combinations, and substitutions can occur, depending on design requirements and other factors. Any modification, equivalent replacement, and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims (11)

1. A method for querying information, comprising:
acquiring first information and first time based on the query request;
if the cache database is stored in the first information, second information and a first time period which are stored in a matching mode with the first information are obtained 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.
2. The method of claim 1, further comprising:
if the first information does not exist in the cache database, second information matched with the first information and a first time period matched with the second information are obtained from the database; storing the first information, the second information and the first time period in a cache database in a matching manner; and determining the second information as a response result of the query request.
3. The method of claim 2, 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 a 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.
4. The method of claim 3, 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, the summary including an identification of the user, a validity period of the summary including the first time;
acquiring a target attribute from the abstract;
and acquiring the value of the target attribute of the item according to the identification of the item of the user and the target attribute.
5. The method of claim 4, wherein obtaining second information from a database that matches the first information comprises:
acquiring the identifier of the abstract from the abstract;
querying the information table containing the identification of the abstract from a database;
and obtaining information matched with both the service type and the value of the target attribute of the article from the information table, and determining the information as second information matched with the first information.
6. The method of claim 5, wherein the determining the first time period comprises:
and determining the intersection of the validity period of the abstract and a service processing time period as the first time period, or directly determining the validity period of the abstract as the first time period.
7. The method of claim 2, wherein storing the first information, and the second information and the first time period match in the cache database comprises:
and matching and storing the first information as a key, the second information and the first time period as values in the cache database in a key value mode.
8. 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 matched with the first information and stored 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.
9. The apparatus of claim 8, wherein the second processing unit is configured to:
if the first information does not exist in the cache database, second information matched with the first information and a first time period matched with the second information are obtained from the database; storing the first information, the second information and the first time period in a cache database in a matching manner; and determining the second information as a response result of the query request.
10. An electronic device, comprising:
one or more processors;
a storage device for storing one or more programs,
when executed by the one or more processors, cause the one or more processors to implement the method of any one of claims 1-7.
11. A computer-readable medium, on which a computer program is stored, which, when being executed by a processor, carries out the method according to any one of claims 1-7.
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 true CN113535769A (en) 2021-10-22
CN113535769B 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)

Cited By (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数据管理与查询优化的研究", 计算机技术与发展, no. 09 *

Cited By (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

Also Published As

Publication number Publication date
CN113535769B (en) 2023-11-03

Similar Documents

Publication Publication Date Title
CN107967284B (en) Method and device for storing and inquiring order information
US10636008B2 (en) Data processing system and method
CN107229718B (en) Method and device for processing report data
CN112884405A (en) Inquiry system and scheduling method thereof
CN103635921A (en) Federated and multi-tenant e-commerce platform
CN111612594A (en) Localized merchant retail system
CN113095893A (en) Method and device for determining sales of articles
CN113535769B (en) Method and device for inquiring information
CN113761565A (en) Data desensitization method and apparatus
CN110858209B (en) Business object access/release method, device and system and electronic equipment
CN110956514A (en) Method and device for generating order information
CN115760300A (en) Method and system for managing sales products based on labels
CN113496386A (en) Method and device for combined charging
CN113762863A (en) Inventory management method and device
CN114445128A (en) Card ticket management method and device, electronic equipment and computer readable medium
CN113762865A (en) Inventory information processing method and device
CN110738806B (en) Payment mode determination method, device and system and electronic equipment
CN113822516A (en) Matching method and device for distribution and transportation side
CN113780921B (en) Price inquiry processing method and device
CN112651536A (en) Method and device for determining delivery address
CN113762835A (en) Method and device for processing order data
KR102560083B1 (en) Method and apparatus for providing a delivery information of product
CN113761077B (en) Method and device for processing bill task
CN111291038B (en) Data query method and device
CN113689223B (en) Information generation method, device, electronic equipment and storage medium

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