Database cache breakdown protection method and system

By using a caching mechanism that dynamically and collaboratively allocates memory and hard disk space, the problem of database cache breakdown in high-concurrency scenarios is solved, improving data access speed and system stability, and achieving balanced use of memory and hard disk space.

CN121144362APending Publication Date: 2025-12-16LINGNAN NORMAL UNIV +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511345003.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-09-19
Publication Date
2025-12-16

AI Technical Summary

Technical Problem

Existing technologies lack effective database cache breakdown protection mechanisms in high-concurrency scenarios, which affects the performance and stability of databases and business systems.

Method used

By dynamically and collaboratively allocating memory and hard disk space, and adjusting the hard disk cache allocation rate according to the real-time memory usage, it ensures that hard disk space is allocated in a timely manner when the memory cache is missed, thus preventing the database from being compromised.

Benefits of technology

It effectively avoids the surge in database pressure caused by cache breakdown in high-concurrency scenarios, improves data access speed, ensures system stability and resource utilization efficiency, and achieves a balanced use of memory and hard disk space.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121144362A_ABST
    Figure CN121144362A_ABST
Patent Text Reader

Abstract

The invention provides a database cache breakdown protection method and system. The method comprises the following steps: acquiring an access request sent to a database by a user; judging whether the access request hits data in the memory space cache or not, and if yes, directly returning the hit data in the memory space cache to the user; otherwise, hard disk space cache is allocated, and the database returns data corresponding to the access request to the user through the hard disk space cache; according to the method, the memory and the hard disk space are dynamically and cooperatively allocated, and the cache allocation rate of the hard disk is automatically adjusted according to the real-time memory utilization rate, so that the sharp increase of database pressure caused by cache breakdown in a high-concurrency scene is effectively avoided, the data access speed is remarkably improved, and meanwhile, the overall stability and the resource utilization efficiency of the system are guaranteed.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of database technology, and more specifically, to a database cache breakdown protection method and system. Background Technology

[0002] In today's society, business system data in various industries are stored in databases. For normal business operations, frequent access to the database is required, which places high demands on the database's ability to quickly access and retrieve data.

[0003] Basic database access methods such as Figure 1 As shown, remote users access the database directly via the public network. For example, when a user visits an e-commerce website, they open a browser on a computer client, enter the specific URL, and access the website. The various products on the website are stored as data in the e-commerce company's database system. All product data is loaded and displayed to the user by accessing the database. However, this basic database access method will place a heavy burden on the e-commerce website's database system under high user traffic, i.e., high concurrency. This not only affects the user experience but also threatens the stable operation of the e-commerce company's business system.

[0004] To improve data access speed in high-concurrency scenarios, database access caching techniques have been invented, such as... Figure 2 As shown, the core of this technology is adding a caching layer between the user and the server. When a user requests data, the system first looks for the required data in the cache. If the data exists in the cache, it is returned directly to the user, avoiding direct access to the database and reducing the database load. If the data is not in the cache, it is then queried from the database, and the result is synchronized to the cache for subsequent requests. This mechanism significantly improves data access efficiency in high-concurrency scenarios while ensuring system stability. However, this technology also has its drawbacks. It cannot cache data indefinitely; it can only cache frequently accessed data. This leads to a problem: currently frequently accessed data will not always be frequently accessed. If at some point some data that was not previously cached arrives, the cache will be breached, and the pressure will still be on the database and business system. In addition, cached frequently accessed data also has a lifespan, i.e., it will age, which also greatly increases the probability of cache breach. Summary of the Invention

[0005] To overcome the shortcomings of the prior art, which lacks a protection mechanism against database cache breakdown and thus affects the performance and stability of the database and business system, this invention provides a database cache breakdown protection method and system. By allocating optimal memory and optimal hard disk space within a specific time period to cache frequently accessed data in the database, the invention prevents the database from being broken down, thereby improving user access speed while ensuring server performance and stability.

[0006] To solve the above-mentioned technical problems, the technical solution of the present invention is as follows: A database cache breakdown protection method includes the following steps: Retrieve the access requests sent by the user to the database; The system determines whether the access request matches data in the memory cache. If it does, the system returns the matched data directly to the user. Otherwise, it allocates disk space for caching, and the database returns the data corresponding to the access request to the user through the disk space cache.

[0007] Preferably, the size of the memory space cache is the maximum value of the access requests per unit time.

[0008] Preferably, the allocation rate of the hard disk space cache is calculated according to the following formula:

[0009] in, The allocation rate for hard disk space cache; The allocation rate variable for hard disk space cache; This represents the current size of the memory cache. This refers to the total size of the memory cache. This is a preset threshold.

[0010] Preferably, the allocation rate variable of the hard disk space cache is calculated according to the following formula. :

[0011] in, For a period of time; This represents the total number of access requests per unit of time.

[0012] Preferably, during the time period Within, the size of the allocated hard disk space cache shall not exceed .

[0013] The present invention also provides a database cache breakdown protection system, comprising: A database is used to store data; The first cache device is used to allocate memory space for caching; The second cache device is used to allocate disk space cache when the memory space cache is not hit; The control module is used to acquire the access request sent by the user to the database; control the first cache device to allocate memory space cache; and determine whether the access request hits the data in the memory space cache. If so, the data hit in the memory space cache is directly returned to the user; otherwise, the control module controls the second cache device to allocate disk space cache, and simultaneously controls the database to return the data corresponding to the access request to the user through the disk space cache.

[0014] Preferably, the size of the memory space cache allocated by the first caching device is the maximum value of the access requests per unit time.

[0015] Preferably, the allocation rate of the hard disk space cache is calculated according to the following formula:

[0016] in, The allocation rate for hard disk space cache; The allocation rate variable for hard disk space cache; This represents the current size of the memory cache. This refers to the total size of the memory cache. This is a preset threshold.

[0017] Preferably, the allocation rate variable of the hard disk space cache is calculated according to the following formula. :

[0018] in, For a period of time; This represents the total number of access requests per unit of time.

[0019] Preferably, during the time period Within, the size of the allocated hard disk space cache shall not exceed .

[0020] Compared with the prior art, the beneficial effects of the technical solution of the present invention are: This invention provides a database cache breakdown protection method and system. First, it obtains the access request sent by the user to the database; then it determines whether the access request hits the data in the memory space cache. If so, the data hit in the memory space cache is directly returned to the user; otherwise, a disk space cache is allocated, and the database returns the data corresponding to the access request to the user through the disk space cache.

[0021] This invention dynamically and collaboratively allocates memory and hard disk space, and automatically adjusts the hard disk cache allocation rate based on real-time memory usage. This effectively avoids the surge in database pressure caused by cache breakdown in high-concurrency scenarios, thereby significantly improving data access speed while ensuring overall system stability and resource utilization efficiency. Without affecting system stability, this invention can automatically coordinate the balance between system memory and hard disk space usage to ensure that the database cache is not broken. Compared with the current method of simply using memory caching technology to solve the database cache breakdown problem, this invention offers higher stability. Attached Figure Description

[0022] Figure 1 This is a schematic diagram of a traditional database access method provided in the background technology.

[0023] Figure 2 This is a schematic diagram of the cache-based database access method provided in the background technology.

[0024] Figure 3 This is a flowchart of a database cache breakdown protection method provided in Example 1.

[0025] Figure 4 This is a flowchart of a database cache breakdown protection method provided in Example 2.

[0026] Figure 5 This is a database cache breakdown protection system architecture diagram provided in Example 3. Detailed Implementation

[0027] The accompanying drawings are for illustrative purposes only and should not be construed as limiting the scope of this application. To better illustrate this embodiment, some parts in the accompanying drawings may be omitted, enlarged, or reduced, and do not represent the actual product dimensions; It will be understood by those skilled in the art that certain well-known structures and their descriptions may be omitted in the accompanying drawings.

[0028] The technical solution of the present invention will be further described below with reference to the accompanying drawings and embodiments.

[0029] Example 1 like Figure 3 As shown, this embodiment provides a database cache breakdown protection method, including the following steps: S1: Obtain the access request sent by the user to the database; S2: Determine whether the access request hits data in the memory space cache. If so, return the data in the memory space cache directly to the user; otherwise, allocate disk space cache, and the database returns the data corresponding to the access request to the user through the disk space cache.

[0030] In the specific implementation process, the system first obtains the access requests sent by users to the database in real time. Under normal circumstances, the system only allocates memory space to cache the database query access requests, and the data hit in the memory space cache is directly returned to the user to improve the speed of accessing the server. When a database access request cannot be found in the memory cache, the system synchronously and linearly increases the disk space, allocates disk space for caching, and helps to open up cache space for the database. At this time, the database returns the data corresponding to the access request to the user through the newly allocated disk space cache. This method can automatically coordinate the balance between system memory and hard disk space usage to ensure that the database cache is not breached without affecting system stability. Compared with the current method of simply using memory caching technology to solve the database cache breach problem, it is more stable.

[0031] Example 2 like Figure 4 As shown, this embodiment provides a database cache breakdown protection method, including the following steps: Retrieve the access requests sent by the user to the database; Determine whether the access request matches data in the memory cache. If it does, return the matched data directly to the user. Otherwise, allocate disk space for caching, and the database returns the data corresponding to the access request to the user through the disk space cache. In this embodiment, the size of the memory space cache is the maximum value of the access requests per unit time. In this embodiment, the allocation rate of the hard disk space cache is calculated according to the following formula:

[0032] in, The allocation rate for hard disk space cache; The allocation rate variable for hard disk space cache; This represents the current size of the memory cache. This refers to the total size of the memory cache. The preset threshold; In this embodiment, the allocation rate variable of the hard disk space cache is calculated according to the following formula. :

[0033] in, For a period of time; The total number of access requests per unit of time; In this embodiment, during the time period Within, the size of the allocated hard disk space cache shall not exceed .

[0034] In the specific implementation process, the system first obtains the access requests sent by users to the database in real time. Under normal circumstances, the system only allocates memory space to cache the database query access requests, and the data hit in the memory space cache is directly returned to the user to improve the speed of accessing the server. In this embodiment, the size of the memory space cache is the maximum value of the access requests per unit time. When a database access request cannot be found in the memory cache, the system synchronously and linearly increases the disk space, allocates disk space for caching, and helps to open up cache space for the database. At this time, the database returns the data corresponding to the access request to the user through the newly allocated disk space cache. In this embodiment, the allocation rate of the hard disk space cache is calculated according to the following formula:

[0035] in, The allocation rate for hard disk space cache; The allocation rate variable for hard disk space cache; This represents the current size of the memory cache. This refers to the total size of the memory cache. The preset threshold; In this embodiment, the allocation rate variable of the hard disk space cache is calculated according to the following formula. :

[0036] in, For a period of time; The total number of access requests per unit of time; After calculating the allocation rate of the hard disk space cache, the size of the hard disk space cache is obtained by integrating the rate over the time interval [0, t]. In this embodiment, during the time period Within the memory, the size of the allocated hard disk space cache has an upper limit, which is the product of the hard disk allocation rate k and the difference between the memory utilization rate and the hard disk allocation size, and can be expressed as: ,in For time period The size of the internally allocated hard disk space cache is further calculated to obtain... ; After allocating specific memory, in the event that the memory cache cannot hit the data, this method uses disk space allocation to help cache database access requests, trading space for time to achieve the goal of quickly hitting the data, effectively preventing the database from being breached, thereby improving user access speed while ensuring server performance and stability.

[0037] Example 3 like Figure 5 As shown, this embodiment provides a database cache breakdown protection system, including: Database 301 is used to store data; The first cache device 302 is used to allocate memory space for caching; The second cache device 303 is used to allocate disk space cache when the memory space cache is missed; The control module 304 is used to obtain the access request sent by the user to the database 301; control the first cache device 302 to allocate memory space cache; and determine whether the access request hits data in the memory space cache. If so, the data hit in the memory space cache is directly returned to the user; otherwise, the control module 304 controls the second cache device 303 to allocate hard disk space cache, and simultaneously controls the database 301 to return the data corresponding to the access request to the user through the hard disk space cache.

[0038] In the specific implementation process, the database 301 stores a large amount of data. The control module 304 obtains the access requests sent by the user to the database in real time. Under normal circumstances, the first cache device 302 only allocates the system's memory space to cache the database query access requests. The data hit in the memory space cache is directly returned to the user to improve the speed of accessing the server. When the access request of database 301 cannot be hit in the cache allocated in memory, the hard disk space is increased synchronously and linearly. The control module 304 controls the second cache device 303 to allocate hard disk space cache to help open up cache space for the database. At this time, the database 301 returns the data corresponding to the access request to the user through the newly allocated hard disk space cache. Without compromising stability, this system can automatically coordinate the balance between memory and disk space usage to prevent database cache from being breached. Compared to the current method of simply using memory caching technology to solve the database cache breach problem, this system offers higher stability.

[0039] The same or similar labels correspond to the same or similar parts; The terms used to describe positional relationships in the accompanying drawings are for illustrative purposes only and should not be construed as limiting this application. Obviously, the above embodiments of the present invention are merely examples for clearly illustrating the present invention, and are not intended to limit the implementation of the present invention. Those skilled in the art can make other variations or modifications based on the above description. It is neither necessary nor possible to exhaustively describe all embodiments here. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention should be included within the scope of protection of the claims of the present invention.

Claims

1. A database cache breakdown protection method, characterized in that, Includes the following steps: Retrieve the access requests sent by the user to the database; Determine whether the access request hits the data in the memory space cache. If so, return the data that hit the memory space cache directly to the user. Otherwise, the database allocates disk space for caching and returns the data corresponding to the access request to the user through the disk space cache.

2. The database cache breakdown protection method according to claim 1, characterized in that, The size of the memory space cache is the maximum value of the access requests per unit time.

3. The database cache breakdown protection method according to claim 1, characterized in that, The allocation rate of the hard disk space cache is calculated using the following formula: in, The allocation rate for hard disk space cache; The allocation rate variable for hard disk space cache; This represents the current size of the memory cache. This refers to the total size of the memory cache. This is a preset threshold.

4. A database cache breakdown protection method according to claim 3, characterized in that, The allocation rate variable of the hard disk space cache is calculated using the following formula. : in, For a period of time; This represents the total number of access requests per unit of time.

5. A database cache breakdown protection method according to claim 4, characterized in that, During the period Within, the size of the allocated hard disk space cache shall not exceed .

6. A database cache breakdown protection system, characterized in that, include: A database is used to store data; The first cache device is used to allocate memory space for caching; The second cache device is used to allocate disk space cache when the memory space cache is missed; The control module is used to obtain access requests sent by users to the database; Control the allocation of memory space for the first cache device; And determine whether the access request hits data in the memory space cache. If so, return the hit data in the memory space cache directly to the user; otherwise, control the second cache device to allocate disk space cache, and at the same time control the database to return the data corresponding to the access request to the user through the disk space cache.

7. A database cache breakdown protection system according to claim 6, characterized in that, The size of the memory space allocated by the first caching device is the maximum value of the access requests per unit time.

8. A database cache breakdown protection system according to claim 6, characterized in that, The allocation rate of the hard disk space cache is calculated using the following formula: in, The allocation rate for hard disk space cache; The allocation rate variable for hard disk space cache; This represents the current size of the memory cache. This refers to the total size of the memory cache. This is a preset threshold.

9. A database cache breakdown protection system according to claim 8, characterized in that, The allocation rate variable of the hard disk space cache is calculated using the following formula. : in, For a period of time; This represents the total number of access requests per unit of time.

10. A database cache breakdown protection system according to claim 9, characterized in that, During the period Within, the size of the allocated hard disk space cache shall not exceed .