CN112015758A - Product code fetching method and device, computer equipment and storage medium - Google Patents

Product code fetching method and device, computer equipment and storage medium Download PDF

Info

Publication number
CN112015758A
CN112015758A CN202010880728.3A CN202010880728A CN112015758A CN 112015758 A CN112015758 A CN 112015758A CN 202010880728 A CN202010880728 A CN 202010880728A CN 112015758 A CN112015758 A CN 112015758A
Authority
CN
China
Prior art keywords
code
fetching
product
preset
hit rate
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
CN202010880728.3A
Other languages
Chinese (zh)
Other versions
CN112015758B (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.)
Ping An Property and Casualty Insurance Company of China Ltd
Original Assignee
Ping An Property and Casualty Insurance Company of China 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 Ping An Property and Casualty Insurance Company of China Ltd filed Critical Ping An Property and Casualty Insurance Company of China Ltd
Priority to CN202010880728.3A priority Critical patent/CN112015758B/en
Publication of CN112015758A publication Critical patent/CN112015758A/en
Application granted granted Critical
Publication of CN112015758B publication Critical patent/CN112015758B/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
    • G06F16/24534Query rewriting; Transformation
    • G06F16/24539Query rewriting; Transformation using cached or materialised query results
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/245Query processing
    • G06F16/2455Query execution
    • 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/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
    • 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)
  • Data Mining & Analysis (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computational Linguistics (AREA)
  • Computing Systems (AREA)
  • Memory System Of A Hierarchy Structure (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The application relates to a product code fetching method and device based on data caching, computer equipment and a storage medium. The method comprises the following steps: and acquiring a target code fetching product corresponding to the received code fetching request and the hit rate of the target code fetching product stored in the first-level cache. And when the hit rate is determined to meet the preset requirement, acquiring the corresponding product number and the preset splicing prefix, and splicing to obtain the code fetching identifier corresponding to the target code fetching product. And determining a second-level cache corresponding to the target code-fetching product according to the code-fetching identifier, and extracting the exchange code corresponding to the target code-fetching product from the second-level cache when the second-level cache is determined to be not empty. By adopting the method, the exchange code corresponding to the target code-fetching product can be directly obtained from the secondary cache in the memory according to the code-fetching request without depending on data to obtain in real time, the burden of a database is reduced, and the acquisition efficiency of the exchange code is improved. In addition, the invention also relates to a block chain technology, and the hit rate of the code fetching product and the attribute information of the exchange code can be stored in the block chain.

Description

Product code fetching method and device, computer equipment and storage medium
Technical Field
The present application relates to the field of internet technologies, and in particular, to a product code fetching method and apparatus, a computer device, and a storage medium.
Background
With the rapid development and popularization of the internet and the coming of the big data era, more and more users realize the popularization of services or products to be sold through the internet. Aiming at the operation and promotion requirements of the products to be sold, the method can be realized by setting corresponding exchange codes for different products, and the user can exchange the corresponding products in a network form according to the held exchange codes, wherein the products can be real or virtual products. The exchange code is a number composed of a group of letters and numbers, the suppliers corresponding to different products are different, and the exchange code corresponding to each product is set by each supplier according to the rule of the supplier.
In actual operation and promotion activities, exchange codes corresponding to products are stored in a database, and in a certain promotion time period of a product to be sold, a plurality of users usually initiate requests to simultaneously access and obtain the same exchange code corresponding to the product, so that the exchange codes are accessed very frequently in a very short time, the problem of hot blocks of the database is caused, the performance of the database is seriously influenced, and the efficiency of providing the corresponding exchange codes for the users is low.
Disclosure of Invention
In view of the above, it is necessary to provide a method, an apparatus, a computer device and a storage medium for acquiring a product code, which can improve the efficiency of acquiring a redemption code.
A method of product code fetching, the method comprising:
receiving a code fetching request, and acquiring a target code fetching product corresponding to the code fetching request;
obtaining the hit rate of the target code fetching product stored in the first-level cache;
when the hit rate of the target code-fetching product in the primary cache is determined to meet the preset requirement, acquiring a product number of the target code-fetching product and a preset splicing prefix for identifying the secondary cache;
splicing the product number and the preset splicing prefix to obtain a code fetching identifier corresponding to the target code fetching product;
determining a second-level cache corresponding to the target code fetching product according to the code fetching identifier;
and when the second-level cache is determined to be not empty, extracting the redemption code corresponding to the target code fetching product from the second-level cache.
In one embodiment, the determining that the hit rate of the target code fetching product in the first-level cache meets a preset requirement includes:
and when the hit rate of the target code fetching product is determined to be greater than a preset hit rate threshold value, determining that the hit rate of the target code fetching product meets the preset requirement.
In one embodiment, the method for updating the hit rate of each code fetching product in the first-level cache includes:
acquiring a product number of a target code fetching product carried by the code fetching request;
and when the target code fetching product exists in the first-level cache according to the product number, increasing the hit rate of the target code fetching product by a preset numerical value, and subtracting the preset numerical value from the hit rates of other code fetching products.
In one embodiment, the second-level cache stores exchange code attribute information corresponding to each code fetching product; the method further comprises the following steps:
in a preset updating time period, obtaining the hit rate of all code fetching products in the first-level cache;
acquiring a preset hit rate threshold;
comparing the hit rate of each code fetching product with the preset hit rate threshold;
and when the code fetching product with the hit rate smaller than the preset hit rate threshold exists, deleting the code fetching product and the corresponding hit rate from the primary cache, and deleting the exchange code attribute information of the code fetching product from the secondary cache.
In one embodiment, after obtaining the hit rates of all code fetching products in the first-level cache within the preset update time period, the method further includes:
recording the current code fetching time of each code fetching product;
acquiring the last code fetching time of each code fetching product;
calculating the interval time between the current code fetching time and the last code fetching time;
acquiring a preset code fetching time threshold;
comparing the interval time with the preset code fetching time threshold;
and when the code fetching product with the interval time larger than the preset code fetching time threshold is determined to exist, deleting the code fetching product and the corresponding hit rate from the primary cache, and deleting the exchange code attribute information of the code fetching product from the secondary cache.
In one embodiment, the method further comprises:
acquiring the creation time of the second-level cache;
and determining the creation time of the second-level cache as a calculation basis of the protection time of the second-level cache.
In one embodiment, before determining that the hit rate of the target code-fetching product meets the preset requirement when determining that the hit rate of the target code-fetching product is greater than a preset hit rate threshold, the method further includes:
acquiring preset hit rates of a preset number of standard code fetching products;
arranging a preset number of preset hit rates according to the value of each preset hit rate to obtain a preset hit rate queue;
acquiring the minimum hit rate in the preset hit rate queue, and determining the minimum hit rate as a preset hit rate threshold;
and comparing the preset hit rate threshold with the hit rate of the target code fetching product.
An apparatus for product coding, the apparatus comprising:
the target code-fetching product acquisition module is used for receiving a code-fetching request and acquiring a target code-fetching product corresponding to the code-fetching request;
the hit rate obtaining module is used for obtaining the hit rate of the target code fetching product in a first-level cache;
the first obtaining module is used for obtaining a product number of the target code-fetching product and a preset splicing prefix for identifying a second-level cache when the hit rate of the target code-fetching product in the first-level cache is determined to meet a preset requirement;
the code fetching identifier generating module is used for splicing the product number and the preset splicing prefix to obtain a code fetching identifier corresponding to the target code fetching product;
the second-level cache determining module is used for determining a second-level cache corresponding to the target code fetching product according to the code fetching identifier;
and the exchange code extracting module is used for extracting the exchange code corresponding to the target code fetching product from the secondary cache when the secondary cache is determined to be not empty.
A computer device comprising a memory and a processor, the memory storing a computer program, the processor implementing the following steps when executing the computer program:
receiving a code fetching request, and acquiring a target code fetching product corresponding to the code fetching request;
obtaining the hit rate of the target code fetching product stored in the first-level cache;
when the hit rate of the target code-fetching product in the primary cache is determined to meet the preset requirement, acquiring a product number of the target code-fetching product and a preset splicing prefix for identifying the secondary cache;
splicing the product number and the preset splicing prefix to obtain a code fetching identifier corresponding to the target code fetching product;
determining a second-level cache corresponding to the target code fetching product according to the code fetching identifier;
and when the second-level cache is determined to be not empty, extracting the redemption code corresponding to the target code fetching product from the second-level cache.
A computer-readable storage medium, on which a computer program is stored which, when executed by a processor, carries out the steps of:
receiving a code fetching request, and acquiring a target code fetching product corresponding to the code fetching request;
obtaining the hit rate of the target code fetching product stored in the first-level cache;
when the hit rate of the target code-fetching product in the primary cache is determined to meet the preset requirement, acquiring a product number of the target code-fetching product and a preset splicing prefix for identifying the secondary cache;
splicing the product number and the preset splicing prefix to obtain a code fetching identifier corresponding to the target code fetching product;
determining a second-level cache corresponding to the target code fetching product according to the code fetching identifier;
and when the second-level cache is determined to be not empty, extracting the redemption code corresponding to the target code fetching product from the second-level cache.
According to the product code fetching method, the device, the computer equipment and the storage medium, the code fetching request is received, the target code fetching product corresponding to the code fetching request is obtained, and the hit rate of the target code fetching product stored in the first-level cache is obtained. And when the hit rate of the target code fetching product in the primary cache meets the preset requirement, acquiring the product number of the target code fetching product and a preset splicing prefix for identifying the secondary cache, and splicing the product number and the preset splicing prefix to obtain a code fetching identifier corresponding to the target code fetching product. And then determining a second-level cache corresponding to the target code-fetching product according to the code-fetching identifier, and extracting the exchange code corresponding to the target code-fetching product from the second-level cache when the second-level cache is determined to be not empty. The exchange code is progressively acquired through the arranged first-level cache and the second-level cache, so that the exchange code corresponding to the target code fetching product can be directly acquired from the second-level cache in the memory according to the code fetching request without depending on data to be acquired in real time, the burden of the database is reduced, the occurrence probability of database hot block problems is reduced, and the acquisition efficiency of the exchange code is further improved.
Drawings
FIG. 1 is a diagram of an exemplary application environment for a product code fetching method;
FIG. 2 is a flow chart illustrating a product code fetching method according to an embodiment;
FIG. 3 is a diagram illustrating a correspondence between a first level cache and a second level cache, according to an embodiment;
FIG. 4 is a flowchart illustrating a product code fetching method according to another embodiment;
FIG. 5 is a block diagram of an embodiment of a product code fetching apparatus;
FIG. 6 is a diagram illustrating an internal structure of a computer device according to an embodiment.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the present application and are not intended to limit the present application.
The product code fetching method provided by the application can be applied to the application environment shown in fig. 1. Wherein the terminal 102 and the server 104 communicate via a network. The server 104 receives a code fetching request initiated by the user based on the terminal 102, and obtains a target code fetching product corresponding to the code fetching request, thereby obtaining a hit rate of the target code fetching product stored in the first-level cache. And when the hit rate of the target code fetching product in the primary cache meets the preset requirement, acquiring the product number of the target code fetching product and a preset splicing prefix for identifying the secondary cache, and splicing the product number and the preset splicing prefix to obtain a code fetching identifier corresponding to the target code fetching product. And then determining a secondary cache corresponding to the target code-fetching product according to the code-fetching identifier, and when the secondary cache is determined to be not empty, extracting the exchange code corresponding to the target code-fetching product from the secondary cache, and feeding the exchange code back to the terminal 102. The terminal 102 may be, but not limited to, various personal computers, notebook computers, smart phones, tablet computers, and portable wearable devices, and the server 104 may be implemented by an independent server or a server cluster formed by a plurality of servers.
In one embodiment, as shown in fig. 2, a product code fetching method is provided, which is described by taking the application of the method to the server in fig. 1 as an example, and includes the following steps:
step S202, receiving the code fetching request, and obtaining a target code fetching product corresponding to the code fetching request.
Specifically, when a code fetching request initiated by a user based on a terminal is received, the code fetching request is analyzed, a product number carried by the code fetching request is obtained, and a corresponding target code fetching product is determined according to the product number. The product number and the target code-fetching product have a one-to-one correspondence relationship, and the unique target code-fetching product can be determined according to the product number.
In one embodiment, before receiving a code fetching request and obtaining a target code fetching product corresponding to the code fetching request, the method further includes:
and acquiring each code fetching product determined based on the service requirement and the corresponding hit rate, and storing each code fetching product and the corresponding hit rate into a first-level cache. And acquiring the attribute information of the exchange codes corresponding to the code-fetching products, and storing the attribute information of the exchange codes in a secondary cache.
The corresponding products and the set rules of the hit rates corresponding to the products are different according to the operation popularization requirements of different customers, and the hit rates obtained by different customers according to different product settings are different. The hit rate represents the number of times that the code-taking product is requested to exchange the code, the exchange code is a number consisting of a group of letters and numbers, different suppliers corresponding to different products are different, and the exchange code corresponding to each product is set by each supplier according to own rules.
Similarly, the initial hit rates of different products are preset by the client to which the product belongs, and if each code-fetching product is requested to exchange codes once, the hit rate is increased by 1, and the hit rates of other code-fetching products in the first-level cache are decreased by 1.
Specifically, in this implementation, as shown in fig. 3, fig. 3 provides a corresponding relationship between a first-level cache and a second-level cache, referring to fig. 3, the first-level cache is used for storing a plurality of code-fetching products and hit rates corresponding to the code-fetching products, and functions as a directory, and the second-level cache stores redemption code attribute information corresponding to the code-fetching products, including a redemption code, a redemption code status, a redemption code expiration date, and the like.
And further, only when the target code fetching product needing code fetching and the hit rate of the target code fetching product are determined to be stored in the first-level cache and the corresponding hit rate is determined to meet the preset requirement, the exchange code corresponding to the target code fetching product is further extracted from the second-level cache.
It should be emphasized that, in order to further ensure the privacy and security of the code fetching product, the hit rate corresponding to the code fetching product, and the exchange code attribute information of the code fetching product, the hit rate corresponding to the code fetching product and the exchange code attribute information of the code fetching product may also be stored in a node of a block chain.
And step S204, acquiring the hit rate of the target code fetching product stored in the first-level cache.
Specifically, each code fetching product and the corresponding hit rate are stored in the first-level cache, and the process of updating the hit rate of each code fetching product is further included in the preset updating time period, so that the obtained hit rate of the target code fetching product is the updated current hit rate in the preset updating time period.
Further, the method for updating the hit rate of each code fetching product in the first-level cache comprises the following steps:
acquiring a product number of a target code fetching product carried by the code fetching request; when the target code fetching product exists in the first-level cache according to the product number, increasing the hit rate of the target code fetching product by a preset value, and subtracting the preset value from the hit rates of other code fetching products.
In this embodiment, the preset value may be 1, that is, when it is determined that the target code fetching product exists in the first-level cache according to the product number, the hit rate of the target code fetching product is increased by 1, and the hit rates of other code fetching products in the first-level cache are subtracted by 1, so that the hit rate of each code fetching product in the first-level cache is updated.
In one embodiment, when it is determined that the target code-fetching product does not exist in the first-level cache, the target code-fetching product is added to the first-level cache, the hit rate of the target code-fetching product in the first-level cache is recorded as 1, and the hit rate of other code-fetching products in the first-level cache is subtracted by a preset value 1.
And step S206, when the hit rate of the target code-fetching product in the primary cache is determined to meet the preset requirement, acquiring the product number of the target code-fetching product and a preset splicing prefix for identifying the secondary cache.
Specifically, when it is determined that the hit rate of the target code fetching product in the first-level cache is greater than a preset hit rate threshold, it is determined that the hit rate of the target code fetching product in the first-level cache meets a preset requirement. And then after the hit rate of the target code fetching product in the first-level cache is determined to meet the preset requirement, the product number of the target code fetching product and a preset splicing prefix for identifying the second-level cache are obtained.
And S208, splicing the product number and the preset splicing prefix to obtain a code fetching identifier corresponding to the target code fetching product.
Specifically, since the second-level cache cannot be directly identified according to the product code, a preset splicing prefix that can be used for identifying the second-level cache is also acquired, and the code fetching identifier corresponding to the target code fetching product can be obtained by splicing the product number and the preset splicing prefix.
For example, if the product number corresponding to the obtained target CODE-fetching product is D12345 and the corresponding preset prefix concatenation is a fits _ release _ CODE, the obtained CODE-fetching identifier is D12346-fits _ release _ CODE in combination with the product number and the preset prefix concatenation. It can be understood that the product numbers of different code fetching products are different, but the preset splicing prefix is used for identifying the second-level cache, and the preset splicing prefixes set for different code fetching products can be the same or different.
And step S210, determining a secondary cache corresponding to the target code-fetching product according to the code-fetching identifier.
Specifically, the preset splicing prefix is used for identifying the second-level cache, and the second-level cache corresponding to the target code-fetching product can be determined by further combining the product number.
The second-level cache stores exchange code attribute information corresponding to each code fetching product, wherein the exchange code attribute information comprises an exchange code, an exchange code state, an exchange code validity period, an exchange code expiration period and the like. The state of the exchange code represents whether the exchange code is available or not, the effective period of the exchange code represents the effective time and the effective duration of the exchange code, the expiration period of the exchange code represents the expiration time of the exchange code, and when the expiration time is reached, the corresponding exchange code cannot be reused.
And step S212, when the second-level cache is determined to be not empty, extracting the exchange code corresponding to the target code fetching product from the second-level cache.
Specifically, after the second-level cache of the target code fetching product is obtained, whether the second-level cache is empty or not is judged. And when the second-level cache is determined to be not empty, extracting the redemption code corresponding to the target code fetching product from the second-level cache.
In one embodiment, when the secondary cache is determined to be empty, the redemption code corresponding to the targeted code-fetching product is extracted from the database. Meanwhile, the prompt information that the second-level cache of the target code-fetching product is empty is pushed to a message queue, and the second-level cache of the target code-fetching product is supplemented according to the prompt information, namely, a redemption code state, a redemption code validity period, a redemption code expiration period and the like corresponding to the target code-fetching product are stored in the second-level cache corresponding to the target code-fetching product.
In the product code fetching method, the target code fetching product corresponding to the code fetching request is obtained by receiving the code fetching request, and the hit rate of the target code fetching product stored in the first-level cache is obtained. And when the hit rate of the target code fetching product in the primary cache meets the preset requirement, acquiring the product number of the target code fetching product and a preset splicing prefix for identifying the secondary cache, and splicing the product number and the preset splicing prefix to obtain a code fetching identifier corresponding to the target code fetching product. And then determining a second-level cache corresponding to the target code-fetching product according to the code-fetching identifier, and extracting the exchange code corresponding to the target code-fetching product from the second-level cache when the second-level cache is determined to be not empty. The exchange code is progressively acquired through the arranged first-level cache and the second-level cache, so that the exchange code corresponding to the target code fetching product can be directly acquired from the second-level cache in the memory according to the code fetching request without depending on data to be acquired in real time, the burden of the database is reduced, the occurrence probability of database hot block problems is reduced, and the acquisition efficiency of the exchange code is further improved.
In one embodiment, the method for determining that the hit rate of the target code fetching product in the first-level cache meets the preset requirement specifically includes the following steps:
acquiring preset hit rates of a preset number of standard code fetching products;
arranging preset hit rates of preset number according to the value of each preset hit rate to obtain a preset hit rate queue;
obtaining the minimum hit rate in a preset hit rate queue, and determining the minimum hit rate as a preset hit rate threshold;
comparing a preset hit rate threshold value with the hit rate of a target code fetching product;
and when the hit rate of the target code fetching product is determined to be greater than the preset hit rate threshold value, determining that the hit rate of the target code fetching product meets the preset requirement.
Specifically, the preset hit rates of the preset number of standard code fetching products are obtained, the preset hit rates of the preset number are sorted according to the value of each preset hit rate, a sorted preset hit rate queue is obtained, the minimum hit rate is extracted from the preset hit rate queue, and the minimum hit rate is determined as a preset hit rate threshold. In this embodiment, the preset number is 10, and the ordered preset hit rate queue includes 10 preset hit rates, and the preset hit rate queue is determined as a preset hit rate threshold by extracting a minimum value of the 10 preset hit rates.
Further, by comparing the preset hit rate threshold with the hit rate of the target code-fetching product, when it is determined that the hit rate of the target code-fetching product is greater than the preset hit rate threshold, it is determined that the hit rate of the target code-fetching product meets the preset requirement, that is, it indicates that the product number of the target code-fetching product and the preset splicing prefix for identifying the secondary cache can be further obtained, so that the secondary cache corresponding to the target code-fetching product can be obtained by splicing.
In this embodiment, a minimum hit rate is determined from preset hit rates corresponding to a plurality of standard code fetching products, and the minimum hit rate is determined as a preset hit rate threshold value for comparison with a hit rate of a target code fetching product, and when it is determined that the hit rate of the target code fetching product is greater than the preset hit rate threshold value, it indicates that the hit rate of the current target code fetching product meets a preset requirement. The progressive acquisition based on the first-level cache and the second-level cache is realized, the dependence on a database is not required, the pressure of the database can be reduced, and the acquisition efficiency of the exchange codes is improved.
In one embodiment, a product code fetching method is provided, which comprises the following steps:
in a preset updating time period, obtaining the hit rate of all code fetching products in the first-level cache;
acquiring a preset hit rate threshold;
comparing the hit rate of each code fetching product with a preset hit rate threshold;
and when the code fetching product with the hit rate smaller than the preset hit rate threshold exists, deleting the code fetching product and the corresponding hit rate from the primary cache, and deleting the exchange code attribute information of the code fetching product from the secondary cache.
Specifically, by presetting an updating time period, the hit rates of all code-fetching products in the first-level cache are obtained in the preset updating time period, and the hit rates of all the code-fetching products are compared with the determined preset hit rate threshold value, so that a corresponding comparison result is obtained. And when determining that code-fetching products with the hit rate smaller than a preset hit rate threshold exist in the primary cache according to the comparison result, deleting the code-fetching products and the corresponding hit rate from the primary cache, and deleting the exchange code information corresponding to the code-fetching products from the secondary cache.
The method is characterized in that a first-level cache and a second-level cache are arranged, the exchange codes corresponding to target code fetching products can be directly obtained from a memory without completely depending on a database, and the problem of hot blocks of the database is reduced.
In this embodiment, by comparing the hit rates of all code fetching products in the first-level cache with the preset hit rate threshold, when there is a code fetching product whose hit rate is less than the preset hit rate threshold, the code fetching product and the corresponding hit rate are deleted from the first-level cache, and the exchange code attribute information of the code fetching product is deleted from the second-level cache, so that the number of created caches is reduced, and the burden on the cluster where the current cache is located is reduced.
In one embodiment, a product code fetching method is provided, which comprises the following steps:
recording the current code fetching time of each code fetching product;
acquiring last code fetching time of each code fetching product;
calculating the interval time between the current code fetching time and the last code fetching time;
acquiring a preset code fetching time threshold;
comparing the interval time with a preset code fetching time threshold;
and when the code fetching product with the interval time larger than the preset code fetching time threshold is determined to exist, deleting the code fetching product and the corresponding hit rate from the primary cache, and deleting the exchange code attribute information of the code fetching product from the secondary cache.
Specifically, the current code fetching time of each code fetching request of the code fetching product is recorded, the last code fetching time of each corresponding code fetching product is obtained, the time interval between the current code fetching time of the code fetching request and the last code fetching time is calculated, the interval time is compared with a preset code fetching time threshold value, and a corresponding comparison result is generated. And when the code fetching product with the interval time larger than the preset code fetching time threshold is determined to exist according to the comparison result, deleting the code fetching product and the corresponding hit rate from the primary cache, and deleting the exchange code attribute information of the code fetching product from the secondary cache.
Because different code fetching products and corresponding exchange codes are set based on different business requirements, in actual operation and popularization activities, when hot holidays exist, the code fetching products which are correspondingly popularized are different from the code fetching products which are popularized on normal working days or off-days. After the hot holiday is finished, the code fetching product which is correspondingly specially popularized cancels corresponding popularization operation activities, and it can be understood that the code fetching product does not belong to the hot product popularized in the hot holiday by calculating the time interval between the current code fetching time of the code fetching request and the last code fetching time and comparing the time interval with a preset code fetching time threshold value, when the time interval is determined to be greater than the preset code fetching time threshold value, the code fetching product and the corresponding hit rate are deleted from the primary cache, and the exchange code attribute information of the code fetching product is deleted from the secondary cache.
Further, in one embodiment, the method further comprises:
acquiring the creation time of a second-level cache;
and determining the creation time of the second-level cache as a calculation basis of the protection time of the second-level cache.
Specifically, when a second-level cache of a certain code fetching product is built, the condition of rejecting the cache may be met immediately, and protection time needs to be given to avoid the problem that resources are occupied by frequent operations due to deletion of the second-level cache just after the second-level cache is built. Wherein, the time for creating the secondary cache is recorded as the basis for calculating the protection time.
In this embodiment, by calculating the interval time between the current code fetching time and the last code fetching time, and comparing the interval time with the preset code fetching time threshold, when it is determined that there is a code fetching product whose interval time is greater than the preset code fetching time threshold, the code fetching product and the corresponding hit rate are deleted from the primary cache, and the exchange code attribute information of the code fetching product is deleted from the secondary cache, the number of created caches and the burden on the cluster where the current cache is located can be reduced.
In one embodiment, as shown in fig. 4, a product code fetching method is provided, which specifically includes the following steps:
1) and acquiring each code fetching product determined based on the service requirement and the corresponding hit rate, and storing each code fetching product and the corresponding hit rate to a first-level cache.
The hit rate represents the number of times that the code-taking product is requested to exchange the code, the exchange code is a number consisting of a group of letters and numbers, different suppliers corresponding to different products are different, and the exchange code corresponding to each product is set by each supplier according to own rules.
2) And acquiring the attribute information of the exchange codes corresponding to the code-fetching products, and storing the attribute information of the exchange codes in a secondary cache.
The second-level cache stores exchange code attribute information corresponding to each code fetching product, wherein the exchange code attribute information comprises an exchange code, an exchange code state, an exchange code validity period, an exchange code expiration period and the like.
3) And receiving a code fetching request, and acquiring a target code fetching product corresponding to the code fetching request.
Specifically, when a code fetching request initiated by a user based on a terminal is received, the code fetching request is analyzed, a product number carried by the code fetching request is obtained, and a corresponding target code fetching product is determined according to the product number.
4) And obtaining the hit rate of the target code fetching product stored in the first-level cache.
In the preset updating time period, the method further comprises a process of updating the hit rate of each code fetching product, and a mode of updating the hit rate of each code fetching product in the first-level cache comprises the following steps:
acquiring a product number of a target code fetching product carried by the code fetching request; when the target code fetching product exists in the first-level cache according to the product number, increasing the hit rate of the target code fetching product by a preset value, and subtracting the preset value from the hit rates of other code fetching products.
5) And acquiring the preset hit rate of the standard code fetching products with preset number.
The preset number can be set by a user or a value range is determined based on service requirements, and the value range is randomly determined from the determined value range.
6) And arranging the preset hit rates of the preset number according to the value of each preset hit rate to obtain a preset hit rate queue.
7) And obtaining the minimum hit rate in the preset hit rate queue, and determining the minimum hit rate as a preset hit rate threshold value.
8) And comparing the preset hit rate threshold with the hit rate of the target code fetching product.
9) And when the hit rate of the target code fetching product is determined to be greater than the preset hit rate threshold value, determining that the hit rate of the target code fetching product meets the preset requirement.
10) And acquiring a product number of the target code-fetching product and a preset splicing prefix for identifying the second-level cache.
11) And splicing the product number and the preset splicing prefix to obtain a code fetching identifier corresponding to the target code fetching product.
And splicing the product number and the preset splicing prefix to obtain a code fetching identifier corresponding to the target code fetching product.
12) And determining a secondary cache corresponding to the target code fetching product according to the code fetching identifier.
13) And when the second-level cache is determined to be not empty, extracting the exchange codes corresponding to the target code fetching products from the second-level cache.
The second-level cache stores exchange code attribute information corresponding to each code fetching product, wherein the exchange code attribute information comprises an exchange code, an exchange code state, an exchange code validity period, an exchange code expiration period and the like. The status of the redemption code indicates whether the redemption code is available, the validity period of the redemption code indicates the time and duration of validity of the redemption code, the expiration period of the redemption code indicates the time of failure of the redemption code, and when the expiration time is reached, the corresponding redemption cannot be reused.
14) And acquiring the product number of the target code-fetching product carried by the code-fetching request within a preset updating time period.
15) When the target code fetching product exists in the first-level cache according to the product number, increasing the hit rate of the target code fetching product by a preset value, and subtracting the preset value from the hit rates of other code fetching products.
Wherein the predetermined value may be 1.
16) And acquiring a preset hit rate threshold, and comparing the hit rate of each code fetching product with the preset hit rate threshold.
17) And when the code fetching product with the hit rate smaller than the preset hit rate threshold exists, deleting the code fetching product and the corresponding hit rate from the primary cache, and deleting the exchange code attribute information of the code fetching product from the secondary cache.
18) And recording the current code fetching time of each code fetching product, and acquiring the last code fetching time of each code fetching product.
19) And calculating the interval time between the current code fetching time and the last code fetching time.
20) And acquiring a preset code fetching time threshold, and comparing the interval time with the preset code fetching time threshold.
21) And when the code fetching product with the interval time larger than the preset code fetching time threshold is determined to exist, deleting the code fetching product and the corresponding hit rate from the primary cache, and deleting the exchange code attribute information of the code fetching product from the secondary cache.
In this embodiment, the target code fetching product corresponding to the code fetching request is obtained by receiving the code fetching request, and the hit rate of the target code fetching product stored in the first-level cache is obtained. And when the hit rate of the target code fetching product in the primary cache meets the preset requirement, acquiring the product number of the target code fetching product and a preset splicing prefix for identifying the secondary cache, and splicing the product number and the preset splicing prefix to obtain a code fetching identifier corresponding to the target code fetching product. And then determining a second-level cache corresponding to the target code-fetching product according to the code-fetching identifier, and extracting the exchange code corresponding to the target code-fetching product from the second-level cache when the second-level cache is determined to be not empty. The exchange code is progressively acquired through the arranged first-level cache and the second-level cache, so that the exchange code corresponding to the target code fetching product can be directly acquired from the second-level cache in the memory according to the code fetching request without depending on data to be acquired in real time, the burden of the database is reduced, the occurrence probability of database hot block problems is reduced, and the acquisition efficiency of the exchange code is further improved.
It should be understood that although the steps in the flowcharts of fig. 2 and 4 are shown in order as indicated by the arrows, the steps are not necessarily performed in order as indicated by the arrows. The steps are not performed in the exact order shown and described, and may be performed in other orders, unless explicitly stated otherwise. Moreover, at least some of the steps in fig. 2 and 4 may include multiple steps or multiple stages, which are not necessarily performed at the same time, but may be performed at different times, which are not necessarily performed in sequence, but may be performed in turn or alternately with other steps or at least some of the other steps.
In one embodiment, as shown in fig. 5, there is provided a product code fetching apparatus, including: a target code-fetching product obtaining module 502, a hit rate obtaining module 504, a first obtaining module 506, a code-fetching identifier generating module 508, a second level cache determining module 510, and a redemption code extracting module 512, wherein:
the target code-fetching product obtaining module 502 is configured to receive the code-fetching request, and obtain a target code-fetching product corresponding to the code-fetching request.
A hit rate obtaining module 504, configured to obtain a hit rate of the target code fetching product in the first-level cache.
A first obtaining module 506, configured to obtain a product number of the target code fetching product and a preset splicing prefix for identifying the second-level cache when it is determined that the hit rate of the target code fetching product in the first-level cache meets a preset requirement.
And a code-fetching identifier generating module 508, configured to splice the product number and a preset splicing prefix, so as to obtain a code-fetching identifier corresponding to the target code-fetching product.
And a second level cache determining module 510, configured to determine, according to the code fetching identifier, a second level cache corresponding to the target code fetching product.
And the redemption code extracting module 512 is configured to extract a redemption code corresponding to the target code fetching product from the second-level cache when it is determined that the second-level cache is not empty.
In the product code fetching device, the target code fetching product corresponding to the code fetching request is obtained by receiving the code fetching request, and the hit rate of the target code fetching product stored in the first-level cache is obtained. And when the hit rate of the target code fetching product in the primary cache meets the preset requirement, acquiring the product number of the target code fetching product and a preset splicing prefix for identifying the secondary cache, and splicing the product number and the preset splicing prefix to obtain a code fetching identifier corresponding to the target code fetching product. And then determining a second-level cache corresponding to the target code-fetching product according to the code-fetching identifier, and extracting the exchange code corresponding to the target code-fetching product from the second-level cache when the second-level cache is determined to be not empty. The exchange code is progressively acquired through the arranged first-level cache and the second-level cache, so that the exchange code corresponding to the target code fetching product can be directly acquired from the second-level cache in the memory according to the code fetching request without depending on data to be acquired in real time, the burden of the database is reduced, the occurrence probability of database hot block problems is reduced, and the acquisition efficiency of the exchange code is further improved.
In one embodiment, a product code fetching device is provided, which further includes a deleting module, configured to:
in a preset updating time period, obtaining the hit rate of all code fetching products in the first-level cache; acquiring a preset hit rate threshold; comparing the hit rate of each code fetching product with a preset hit rate threshold; and when the code fetching product with the hit rate smaller than the preset hit rate threshold exists, deleting the code fetching product and the corresponding hit rate from the primary cache, and deleting the exchange code attribute information of the code fetching product from the secondary cache.
In this embodiment, by comparing the hit rates of all code fetching products in the first-level cache with the preset hit rate threshold, when there is a code fetching product whose hit rate is less than the preset hit rate threshold, the code fetching product and the corresponding hit rate are deleted from the first-level cache, and the exchange code attribute information of the code fetching product is deleted from the second-level cache, so that the number of created caches is reduced, and the burden on the cluster where the current cache is located is reduced.
In one embodiment, the deletion module is further to:
recording the current code fetching time of each code fetching product; acquiring last code fetching time of each code fetching product; calculating the interval time between the current code fetching time and the last code fetching time; acquiring a preset code fetching time threshold; comparing the interval time with a preset code fetching time threshold; and when the code fetching product with the interval time larger than the preset code fetching time threshold is determined to exist, deleting the code fetching product and the corresponding hit rate from the primary cache, and deleting the exchange code attribute information of the code fetching product from the secondary cache.
In this embodiment, by calculating the interval time between the current code fetching time and the last code fetching time, and comparing the interval time with the preset code fetching time threshold, when it is determined that there is a code fetching product whose interval time is greater than the preset code fetching time threshold, the code fetching product and the corresponding hit rate are deleted from the primary cache, and the exchange code attribute information of the code fetching product is deleted from the secondary cache, the number of created caches and the burden on the cluster where the current cache is located can be reduced.
In one embodiment, the first obtaining module is further configured to:
acquiring preset hit rates of a preset number of standard code fetching products; arranging preset hit rates of preset number according to the value of each preset hit rate to obtain a preset hit rate queue; obtaining the minimum hit rate in a preset hit rate queue, and determining the minimum hit rate as a preset hit rate threshold; comparing a preset hit rate threshold value with the hit rate of a target code fetching product; and when the hit rate of the target code fetching product is determined to be greater than the preset hit rate threshold value, determining that the hit rate of the target code fetching product meets the preset requirement.
In this embodiment, a minimum hit rate is determined from preset hit rates corresponding to a plurality of standard code fetching products, and the minimum hit rate is determined as a preset hit rate threshold value for comparison with a hit rate of a target code fetching product, and when it is determined that the hit rate of the target code fetching product is greater than the preset hit rate threshold value, it indicates that the hit rate of the current target code fetching product meets a preset requirement. The progressive acquisition based on the first-level cache and the second-level cache is realized, the dependence on a database is not required, the pressure of the database can be reduced, and the acquisition efficiency of the exchange codes is improved.
In one embodiment, a product code fetching apparatus is provided, which further includes an update module, configured to:
acquiring a product number of a target code fetching product carried by the code fetching request; when the target code fetching product exists in the first-level cache according to the product number, increasing the hit rate of the target code fetching product by a preset value, and subtracting the preset value from the hit rates of other code fetching products.
For specific limitations of the product code fetching device, reference may be made to the above limitations of the product code fetching method, which are not described herein again. The modules in the code fetching device of the product can be wholly or partially realized by software, hardware and a combination thereof. The modules can be embedded in a hardware form or independent from a processor in the computer device, and can also be stored in a memory in the computer device in a software form, so that the processor can call and execute operations corresponding to the modules.
In one embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as shown in fig. 6. The computer device includes a processor, a memory, and a network interface connected by a system bus. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device comprises a nonvolatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program, and a database. The internal memory provides an environment for the operation of an operating system and computer programs in the non-volatile storage medium. The database of the computer equipment is used for storing code fetching products, hit rates corresponding to the code fetching products and exchange code attribute information corresponding to the code fetching products. The network interface of the computer device is used for communicating with an external terminal through a network connection. The computer program is executed by a processor to implement a method of code fetching for a product.
Those skilled in the art will appreciate that the architecture shown in fig. 6 is merely a block diagram of some of the structures associated with the disclosed aspects and is not intended to limit the computing devices to which the disclosed aspects apply, as particular computing devices may include more or less components than those shown, or may combine certain components, or have a different arrangement of components.
In one embodiment, a computer device is provided, comprising a memory and a processor, the memory having a computer program stored therein, the processor implementing the following steps when executing the computer program:
receiving a code fetching request, and acquiring a target code fetching product corresponding to the code fetching request;
obtaining the hit rate of a target code fetching product stored in a first-level cache;
when the hit rate of a target code fetching product in a primary cache is determined to meet a preset requirement, acquiring a product number of the target code fetching product and a preset splicing prefix for identifying a secondary cache;
splicing the product number and a preset splicing prefix to obtain a code fetching identifier corresponding to a target code fetching product;
determining a second-level cache corresponding to the target code-fetching product according to the code-fetching identifier;
and when the second-level cache is determined to be not empty, extracting the exchange codes corresponding to the target code fetching products from the second-level cache.
In one embodiment, the processor, when executing the computer program, further performs the steps of:
and when the hit rate of the target code fetching product is determined to be greater than the preset hit rate threshold value, determining that the hit rate of the target code fetching product meets the preset requirement.
In one embodiment, the processor, when executing the computer program, further performs the steps of:
acquiring a product number of a target code fetching product carried by the code fetching request;
when the target code fetching product exists in the first-level cache according to the product number, increasing the hit rate of the target code fetching product by a preset value, and subtracting the preset value from the hit rates of other code fetching products.
In one embodiment, the processor, when executing the computer program, further performs the steps of:
in a preset updating time period, obtaining the hit rate of all code fetching products in the first-level cache;
acquiring a preset hit rate threshold;
comparing the hit rate of each code fetching product with a preset hit rate threshold;
and when the code fetching product with the hit rate smaller than the preset hit rate threshold exists, deleting the code fetching product and the corresponding hit rate from the primary cache, and deleting the exchange code attribute information of the code fetching product from the secondary cache.
In one embodiment, the processor, when executing the computer program, further performs the steps of:
recording the current code fetching time of each code fetching product;
acquiring last code fetching time of each code fetching product;
calculating the interval time between the current code fetching time and the last code fetching time;
acquiring a preset code fetching time threshold;
comparing the interval time with a preset code fetching time threshold;
and when the code fetching product with the interval time larger than the preset code fetching time threshold is determined to exist, deleting the code fetching product and the corresponding hit rate from the primary cache, and deleting the exchange code attribute information of the code fetching product from the secondary cache.
In one embodiment, the processor, when executing the computer program, further performs the steps of:
acquiring the creation time of a second-level cache;
and determining the creation time of the second-level cache as a calculation basis of the protection time of the second-level cache.
In one embodiment, the processor, when executing the computer program, further performs the steps of:
acquiring preset hit rates of a preset number of standard code fetching products;
arranging preset hit rates of preset number according to the value of each preset hit rate to obtain a preset hit rate queue;
obtaining the minimum hit rate in a preset hit rate queue, and determining the minimum hit rate as a preset hit rate threshold;
and comparing the preset hit rate threshold with the hit rate of the target code fetching product.
In one embodiment, a computer-readable storage medium is provided, having a computer program stored thereon, which when executed by a processor, performs the steps of:
receiving a code fetching request, and acquiring a target code fetching product corresponding to the code fetching request;
obtaining the hit rate of a target code fetching product stored in a first-level cache;
when the hit rate of a target code fetching product in a primary cache is determined to meet a preset requirement, acquiring a product number of the target code fetching product and a preset splicing prefix for identifying a secondary cache;
splicing the product number and a preset splicing prefix to obtain a code fetching identifier corresponding to a target code fetching product;
determining a second-level cache corresponding to the target code-fetching product according to the code-fetching identifier;
and when the second-level cache is determined to be not empty, extracting the exchange codes corresponding to the target code fetching products from the second-level cache.
In one embodiment, the computer program when executed by the processor further performs the steps of:
and when the hit rate of the target code fetching product is determined to be greater than the preset hit rate threshold value, determining that the hit rate of the target code fetching product meets the preset requirement.
In one embodiment, the method for updating the hit rate of each code fetching product in the first-level cache comprises the following steps:
in one embodiment, the computer program when executed by the processor further performs the steps of:
acquiring a product number of a target code fetching product carried by the code fetching request;
when the target code fetching product exists in the first-level cache according to the product number, increasing the hit rate of the target code fetching product by a preset value, and subtracting the preset value from the hit rates of other code fetching products.
In one embodiment, the computer program when executed by the processor further performs the steps of:
in a preset updating time period, obtaining the hit rate of all code fetching products in the first-level cache;
acquiring a preset hit rate threshold;
comparing the hit rate of each code fetching product with a preset hit rate threshold;
and when the code fetching product with the hit rate smaller than the preset hit rate threshold exists, deleting the code fetching product and the corresponding hit rate from the primary cache, and deleting the exchange code attribute information of the code fetching product from the secondary cache.
In one embodiment, the computer program when executed by the processor further performs the steps of:
recording the current code fetching time of each code fetching product;
acquiring last code fetching time of each code fetching product;
calculating the interval time between the current code fetching time and the last code fetching time;
acquiring a preset code fetching time threshold;
comparing the interval time with a preset code fetching time threshold;
and when the code fetching product with the interval time larger than the preset code fetching time threshold is determined to exist, deleting the code fetching product and the corresponding hit rate from the primary cache, and deleting the exchange code attribute information of the code fetching product from the secondary cache.
In one embodiment, the computer program when executed by the processor further performs the steps of:
acquiring the creation time of a second-level cache;
and determining the creation time of the second-level cache as a calculation basis of the protection time of the second-level cache.
In one embodiment, the computer program when executed by the processor further performs the steps of:
acquiring preset hit rates of a preset number of standard code fetching products;
arranging preset hit rates of preset number according to the value of each preset hit rate to obtain a preset hit rate queue;
obtaining the minimum hit rate in a preset hit rate queue, and determining the minimum hit rate as a preset hit rate threshold;
and comparing the preset hit rate threshold with the hit rate of the target code fetching product.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by hardware instructions of a computer program, which can be stored in a non-volatile computer-readable storage medium, and when executed, can include the processes of the embodiments of the methods described above. Any reference to memory, storage, database or other medium used in the embodiments provided herein can include at least one of non-volatile and volatile memory. Non-volatile Memory may include Read-Only Memory (ROM), magnetic tape, floppy disk, flash Memory, optical storage, or the like. Volatile Memory can include Random Access Memory (RAM) or external cache Memory. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM), among others.
The block chain is a novel application mode of computer technologies such as distributed data storage, point-to-point transmission, a consensus mechanism, an encryption algorithm and the like. A block chain (Blockchain), which is essentially a decentralized database, is a series of data blocks associated by using a cryptographic method, and each data block contains information of a batch of network transactions, so as to verify the validity (anti-counterfeiting) of the information and generate a next block. The blockchain may include a blockchain underlying platform, a platform product service layer, an application service layer, and the like.
The technical features of the above embodiments can be arbitrarily combined, and for the sake of brevity, all possible combinations of the technical features in the above embodiments are not described, but should be considered as the scope of the present specification as long as there is no contradiction between the combinations of the technical features.
The above-mentioned embodiments only express several embodiments of the present application, and the description thereof is more specific and detailed, but not construed as limiting the scope of the invention. It should be noted that, for a person skilled in the art, several variations and modifications can be made without departing from the concept of the present application, which falls within the scope of protection of the present application. Therefore, the protection scope of the present patent shall be subject to the appended claims.

Claims (10)

1. A method for code fetching of a product, the method comprising:
receiving a code fetching request, and acquiring a target code fetching product corresponding to the code fetching request;
obtaining the hit rate of the target code fetching product stored in the first-level cache;
when the hit rate of the target code-fetching product in the primary cache is determined to meet the preset requirement, acquiring a product number of the target code-fetching product and a preset splicing prefix for identifying the secondary cache;
splicing the product number and the preset splicing prefix to obtain a code fetching identifier corresponding to the target code fetching product;
determining a second-level cache corresponding to the target code fetching product according to the code fetching identifier;
and when the second-level cache is determined to be not empty, extracting the redemption code corresponding to the target code fetching product from the second-level cache.
2. The method of claim 1, wherein determining a hit rate of the target code fetching product in the level one cache meets a predetermined requirement comprises:
and when the hit rate of the target code fetching product is determined to be greater than a preset hit rate threshold value, determining that the hit rate of the target code fetching product meets the preset requirement.
3. The method of claim 1, wherein updating the hit rate of each of the code-fetching products in the level one cache comprises:
acquiring a product number of a target code fetching product carried by the code fetching request;
and when the target code fetching product exists in the first-level cache according to the product number, increasing the hit rate of the target code fetching product by a preset numerical value, and subtracting the preset numerical value from the hit rates of other code fetching products.
4. The method of claim 3, wherein the second-level cache stores therein redemption code attribute information corresponding to each of the code-fetched products; the method further comprises the following steps:
in a preset updating time period, obtaining the hit rate of all code fetching products in the first-level cache;
acquiring a preset hit rate threshold;
comparing the hit rate of each code fetching product with the preset hit rate threshold;
and when the code fetching product with the hit rate smaller than the preset hit rate threshold exists, deleting the code fetching product and the corresponding hit rate from the primary cache, and deleting the exchange code attribute information of the code fetching product from the secondary cache.
5. The method according to claim 4, further comprising, after obtaining hit rates of all code-fetching products in the level one cache within the preset update time period:
recording the current code fetching time of each code fetching product;
acquiring the last code fetching time of each code fetching product;
calculating the interval time between the current code fetching time and the last code fetching time;
acquiring a preset code fetching time threshold;
comparing the interval time with the preset code fetching time threshold;
and when the code fetching product with the interval time larger than the preset code fetching time threshold is determined to exist, deleting the code fetching product and the corresponding hit rate from the primary cache, and deleting the exchange code attribute information of the code fetching product from the secondary cache.
6. The method of claim 5, further comprising:
acquiring the creation time of the second-level cache;
and determining the creation time of the second-level cache as a calculation basis of the protection time of the second-level cache.
7. The method according to claim 2, wherein before determining that the hit rate of the target code-fetching product meets the preset requirement when determining that the hit rate of the target code-fetching product is greater than a preset hit rate threshold, further comprising:
acquiring preset hit rates of a preset number of standard code fetching products;
arranging a preset number of preset hit rates according to the value of each preset hit rate to obtain a preset hit rate queue;
acquiring the minimum hit rate in the preset hit rate queue, and determining the minimum hit rate as a preset hit rate threshold;
and comparing the preset hit rate threshold with the hit rate of the target code fetching product.
8. A product code fetching apparatus, the apparatus comprising:
the target code-fetching product acquisition module is used for receiving a code-fetching request and acquiring a target code-fetching product corresponding to the code-fetching request;
the hit rate obtaining module is used for obtaining the hit rate of the target code fetching product in a first-level cache;
the first obtaining module is used for obtaining a product number of the target code-fetching product and a preset splicing prefix for identifying a second-level cache when the hit rate of the target code-fetching product in the first-level cache is determined to meet a preset requirement;
the code fetching identifier generating module is used for splicing the product number and the preset splicing prefix to obtain a code fetching identifier corresponding to the target code fetching product;
the second-level cache determining module is used for determining a second-level cache corresponding to the target code fetching product according to the code fetching identifier;
and the exchange code extracting module is used for extracting the exchange code corresponding to the target code fetching product from the secondary cache when the secondary cache is determined to be not empty.
9. A computer device comprising a memory and a processor, the memory storing a computer program, characterized in that the processor, when executing the computer program, implements the steps of the method of any of claims 1 to 7.
10. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the steps of the method of any one of claims 1 to 7.
CN202010880728.3A 2020-08-27 2020-08-27 Product code-fetching method, device, computer equipment and storage medium Active CN112015758B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010880728.3A CN112015758B (en) 2020-08-27 2020-08-27 Product code-fetching method, device, computer equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010880728.3A CN112015758B (en) 2020-08-27 2020-08-27 Product code-fetching method, device, computer equipment and storage medium

Publications (2)

Publication Number Publication Date
CN112015758A true CN112015758A (en) 2020-12-01
CN112015758B CN112015758B (en) 2023-07-28

Family

ID=73502529

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010880728.3A Active CN112015758B (en) 2020-08-27 2020-08-27 Product code-fetching method, device, computer equipment and storage medium

Country Status (1)

Country Link
CN (1) CN112015758B (en)

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101635001A (en) * 2008-07-18 2010-01-27 QlikTech国际公司 Method and apparatus for extracting information from a database
CN108573402A (en) * 2018-03-12 2018-09-25 阿里巴巴集团控股有限公司 A kind of redemption code distribution method, server and system
CN109583894A (en) * 2018-11-28 2019-04-05 阿里巴巴集团控股有限公司 Offer, verification method and the device of two dimensional code
US20190213085A1 (en) * 2018-01-11 2019-07-11 Robin Systems, Inc. Implementing Fault Domain And Latency Requirements In A Virtualized Distributed Storage System
CN110232601A (en) * 2019-06-18 2019-09-13 深圳前海微众银行股份有限公司 Card certificate management method, device, equipment and storage medium
CN110297807A (en) * 2019-07-01 2019-10-01 深圳盒子信息科技有限公司 A kind of two dimension code management method and device
CN111506603A (en) * 2020-04-23 2020-08-07 上海达梦数据库有限公司 Data processing method, device, equipment and storage medium

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101635001A (en) * 2008-07-18 2010-01-27 QlikTech国际公司 Method and apparatus for extracting information from a database
US20190213085A1 (en) * 2018-01-11 2019-07-11 Robin Systems, Inc. Implementing Fault Domain And Latency Requirements In A Virtualized Distributed Storage System
CN108573402A (en) * 2018-03-12 2018-09-25 阿里巴巴集团控股有限公司 A kind of redemption code distribution method, server and system
CN109583894A (en) * 2018-11-28 2019-04-05 阿里巴巴集团控股有限公司 Offer, verification method and the device of two dimensional code
CN110232601A (en) * 2019-06-18 2019-09-13 深圳前海微众银行股份有限公司 Card certificate management method, device, equipment and storage medium
CN110297807A (en) * 2019-07-01 2019-10-01 深圳盒子信息科技有限公司 A kind of two dimension code management method and device
CN111506603A (en) * 2020-04-23 2020-08-07 上海达梦数据库有限公司 Data processing method, device, equipment and storage medium

Also Published As

Publication number Publication date
CN112015758B (en) 2023-07-28

Similar Documents

Publication Publication Date Title
CN110597825B (en) Data processing method and device based on block chain and node equipment
CN112099979B (en) Access control method, device, computer equipment and storage medium
CN109918382A (en) Data processing method, device, terminal and storage medium
CN111652685A (en) Information processing method, information processing device, computer equipment and computer readable storage medium
CN112491930B (en) System risk dynamic monitoring method, system, computer equipment and storage medium
CN108512948B (en) Address book updating method and device, computer equipment and storage medium
CN111177121A (en) Order data feedback method and device, computer equipment and storage medium
CN111488626A (en) Data processing method, device, equipment and medium based on block chain
CN112506481A (en) Service data interaction method and device, computer equipment and storage medium
CN113949579B (en) Website attack defense method and device, computer equipment and storage medium
CN108389124B (en) Data processing method, data processing device, computer equipment and storage medium
CN111080233B (en) Method, device and storage medium for generating subscription information
CN112862455A (en) Test execution work order generation method and device, computer equipment and storage medium
CN112015758B (en) Product code-fetching method, device, computer equipment and storage medium
CN116303343A (en) Data slicing method, device, electronic equipment and storage medium
CN112783866A (en) Data reading method and device, computer equipment and storage medium
CN110460585B (en) Equipment identity identification method and device, computer equipment and storage medium
CN112800123A (en) Data processing method, data processing device, computer equipment and storage medium
JP2014524210A (en) Generate variable length nonce
CN112862454A (en) Test execution work order updating method and device, computer equipment and storage medium
CN106339376B (en) Method and device for identifying hot microblog
CN116522395B (en) Method and system for processing data files in big data storage system
CN112800033B (en) Data operation request processing method and device, computer equipment and storage medium
CN110969430A (en) Method and device for identifying suspicious user, computer equipment and storage medium
CN111191082A (en) Data management method and device, computer 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