Software cache region management method and device, equipment and storage medium

By creating multiple fixed-size data areas in the software cache area and recording status information, the problem of failure to release the cache area in the existing technology and insufficient fixed-size in the fixed-size is solved, and efficient management of the cache area and timely release of memory is achieved.

CN119512456APending Publication Date: 2025-02-25厦门天锐科技股份有限公司
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411563815.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-05
Publication Date
2025-02-25

AI Technical Summary

Technical Problem

The existing software cache area has problems such as failure to release in time, frequent memory application and insufficient fixed size, resulting in waste of memory resources and poor compatibility.

Method used

By creating a cache area including multiple fixed-size data areas and recording the data area number and status information of each data area, the cache area is managed according to the status information, including writing, reading and releasing data areas.

Benefits of technology

It realizes timely release of memory, reduces resource usage, avoids frequent memory application, and improves the dynamicity and compatibility of the cache area.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119512456A_ABST
    Figure CN119512456A_ABST
Patent Text Reader

Abstract

The invention provides a software cache region management method and device, equipment and a medium, and relates to the technical field of computers. The method comprises the following steps: creating a cache region comprising a plurality of data regions with fixed sizes according to a received cache region creation request, and recording a data region number and state information of each data region; when a cache writing request is received, writing data into the cache region according to the state information of each data region in the cache region; when a cache reading request is received, reading data from the cache region according to the data region number and the state information of each data region in the cache region; managing the cache region according to the state information of each data region in the cache region; wherein the state information comprises a use state, a data type and a data length of the stored data, and a timestamp, and the data type comprises single-use data, multi-use data and long-term valid data. According to the method, the cache data area is pre-developed, frequent memory application is avoided, the memory can be released in time, and resource occupation is reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a method, device, equipment and storage medium for managing a software cache area. Background Art

[0002] Buffer is a memory area in a computer system used to temporarily store data. Its main function is to improve data processing efficiency and solve the speed difference between data producers and consumers.

[0003] Most software will allocate a cache when running to pass data between functions. As the size and complexity of software grows, cache usage also increases. There may be a large amount of dirty data in the cache, resulting in a waste of memory resources. Alternatively, only a fixed-size cache is allocated to the software, and the version needs to be upgraded again when a new scenario appears, resulting in poor compatibility.

[0004] Therefore, the existing software cache has some defects: it is not released in time, and the old data is erased only when new data needs to be written; memory is frequently requested; the size is fixed and cannot be created dynamically. Summary of the invention

[0005] The purpose of the present application is to provide a software cache management method, device, electronic device and storage medium to solve at least one problem existing in the above-mentioned prior art.

[0006] In a first aspect, an embodiment of the present application provides a method for managing a software cache area, including:

[0007] Creating a cache area including a plurality of fixed-size data areas according to the received cache area creation request, and recording a data area number and status information of each of the data areas;

[0008] When receiving a write cache request, writing data into the cache area according to the status information of each data area in the cache area;

[0009] When receiving a cache read request, reading data from the cache area according to the data area number and status information of each data area in the cache area;

[0010] Managing the cache area according to the status information of each data area in the cache area;

[0011] The state information includes the usage state, the data type and data length of the stored data, and a timestamp. The data type includes single-use data, multiple-use data, and long-term valid data.

[0012] In a possible implementation, writing data into the cache area according to the status information of each data area in the cache area includes:

[0013] Determining whether there is an available data area in the cache area according to the status information of each data area in the cache area;

[0014] If there is no available data area, apply for a new memory as a new data area, write the data into the new data area, and record the data area number and status information of the new data area;

[0015] If there is currently an available data area, the data is written to the available data area, and the timestamp in the data area is updated after the writing is successful.

[0016] In a possible implementation, reading data from the cache area according to the data area number and status information of each data area in the cache area includes:

[0017] Data is read from the corresponding data area in the buffer area according to the data area number and data type, and the timestamp in the data area is updated after the reading is successful.

[0018] In a possible implementation, managing the cache area according to the status information of each data area in the cache area includes:

[0019] For single-use data in a data area, the data area is cleared after reading, and the timestamp in the data area is updated;

[0020] For the data in the data area that is used multiple times, an available number is set. When the available number is zero, the data area is cleared and the timestamp in the data area is updated;

[0021] For each data area, determine the difference between the timestamp in the data area and the current time. If the difference exceeds a preset time range, clear the data area and update the timestamp in the data area.

[0022] If the data area is a new data area created by applying for new memory and is not occupied, the difference between the timestamp in the new data area and the current time is determined. If the difference exceeds a preset time range, the new data area is released.

[0023] In a second aspect, an embodiment of the present application provides a software cache management device, including:

[0024] A creation module, used to create a cache area including a plurality of fixed-size data areas according to a received cache area creation request, and record a data area number and status information of each of the data areas;

[0025] A writing module, configured to write data into the cache area according to the status information of each data area in the cache area when receiving a write cache request;

[0026] A reading module, configured to read data from the cache area according to the data area number and status information of each data area in the cache area when receiving a cache read request;

[0027] A management module, used for managing the cache area according to the status information of each data area in the cache area;

[0028] The state information includes the usage state, the data type and data length of the stored data, and a timestamp. The data type includes single-use data, multiple-use data, and long-term valid data.

[0029] In a possible implementation, the writing module is specifically used to:

[0030] Determining whether there is an available data area in the cache area according to the status information of each data area in the cache area;

[0031] If there is no available data area, apply for a new memory as a new data area, write the data into the new data area, and record the data area number and status information of the new data area;

[0032] If there is currently an available data area, the data is written to the available data area, and the timestamp in the data area is updated after the writing is successful.

[0033] In a possible implementation, the reading module is specifically used to:

[0034] Data is read from the corresponding data area in the buffer area according to the data area number and data type, and the timestamp in the data area is updated after the reading is successful.

[0035] In a possible implementation, the management module is specifically used to:

[0036] For single-use data in a data area, the data area is cleared after reading, and the timestamp in the data area is updated;

[0037] For the data in the data area that is used multiple times, an available number is set. When the available number is zero, the data area is cleared and the timestamp in the data area is updated;

[0038] For each data area, determine the difference between the timestamp in the data area and the current time. If the difference exceeds a preset time range, clear the data area and update the timestamp in the data area.

[0039] If the data area is a new data area created by applying for new memory and is not occupied, the difference between the timestamp in the new data area and the current time is determined. If the difference exceeds a preset time range, the new data area is released.

[0040] In a third aspect, the present application provides an electronic device, comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the method described in the first aspect.

[0041] In a fourth aspect, the present application provides a computer-readable storage medium having computer-readable instructions stored thereon, wherein the computer-readable instructions can be executed by a processor to implement the method described in the first aspect.

[0042] Compared with the prior art, the software cache management method provided by the present application creates a cache including multiple fixed-size data areas according to the received cache creation request, and records the data area number and status information of each data area; when receiving a write cache request, writes data into the cache according to the status information of each data area in the cache; when receiving a read cache request, reads data from the cache according to the data area number and status information of each data area in the cache; manages the cache according to the status information of each data area in the cache; wherein the status information includes the usage status, the data type and data length of the stored data, and the timestamp, and the data type includes single-use data, multiple-use data, and long-term valid data. Compared with the prior art, the present application pre-opens a cache data area, distinguishes the timing of clearing the data area and releasing the memory, avoids frequent memory application, can release the memory in time, and reduces the occupation of resources. BRIEF DESCRIPTION OF THE DRAWINGS

[0043] Various other advantages and benefits will become apparent to those of ordinary skill in the art by reading the detailed description of the preferred embodiments below. The accompanying drawings are only for the purpose of illustrating the preferred embodiments and are not to be considered as limiting the present application. Also, the same reference symbols are used throughout the accompanying drawings to represent the same components. In the accompanying drawings:

[0044] Figure 1 A flowchart of a software cache management method provided by an embodiment of the present application is shown;

[0045] Figure 2 A schematic diagram showing the distribution of pre-created data areas provided in an embodiment of the present application is shown;

[0046] Figure 3 A schematic diagram of a software cache management device provided in an embodiment of the present application is shown;

[0047] Figure 4 A schematic diagram of an electronic device provided in an embodiment of the present application is shown. DETAILED DESCRIPTION

[0048] The exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be limited by the embodiments described herein. On the contrary, these embodiments are provided in order to enable a more thorough understanding of the present disclosure and to fully convey the scope of the present disclosure to those skilled in the art.

[0049] It should be noted that, unless otherwise specified, the technical terms or scientific terms used in this application should have the common meanings understood by technicians in the field to which this application belongs.

[0050] In addition, the terms "first" and "second" etc. are used to distinguish different objects, rather than to describe a specific order. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not limited to the listed steps or units, but may optionally include steps or units that are not listed, or may optionally include other steps or units that are inherent to these processes, methods, products or devices.

[0051] Please refer to Figure 1 , Figure 1 1 is a flowchart of a software cache management method provided by an embodiment of the present application. The present application can be applied to a terminal. The method includes the following steps S101 to S104:

[0052] S101. Create a cache area including a plurality of fixed-size data areas according to a received cache area creation request, and record a data area number and status information of each of the data areas;

[0053] The cache creation request includes the type and length of the commonly used data of the software. The size of the data area can be set with reference to the length of the commonly used data of the software, and the number of data areas can be determined with reference to the number of commonly used data of the software.

[0054] The state information includes the usage state, the data type and data length of the stored data, and a timestamp. The data type includes single-use data, multiple-use data, and long-term valid data.

[0055] The usage status of the data area can be occupied or unoccupied. Unoccupied means it is an idle data area where data can be written.

[0056] The timestamp indicates the time of operations such as writing data, reading data, or clearing data in the data area. The expired cache can be determined based on the timestamp, and the difference between the timestamp in the data area and the current time can be determined. If it exceeds the preset time range, it will be marked as invalid data, the invalid data will be cleared, and the timestamp will be updated.

[0057] In this application, a cache area is pre-opened. When the cache area is created, N fixed-size data areas are preset to store commonly used data. It is not necessary to apply for memory every time data is stored, which reduces the frequent application of memory. Figure 2 The figure shows a distribution diagram of the data area pre-created in the present application, wherein NO represents the data area number; STATE represents the usage status of the data area, USED represents occupied, and NULL represents unoccupied; TYPE represents the data type of the stored data; DATALEN represents the data length of the stored data, and DATA represents the stored data.

[0058] S102, when receiving a write cache request, writing data into the cache area according to the status information of each data area in the cache area;

[0059] Specifically, the above step S102 can be implemented as follows: based on the status information of each data area in the cache area, determine whether there is an available data area in the cache area; if there is no available data area at present, apply for new memory as a new data area, write data into the new data area, and record the data area number and status information of the new data area; if there is an available data area at present, write the data into the available data area, and update the timestamp in the data area after successful writing.

[0060] When writing to the cache, this application will first store the already opened and free data area. If there is no free data area available, it will apply for new memory as a new data area, mark the usage status as occupied, and record the data area number. Each write will update the timestamp in the data area. It can be seen that this application has both pre-opened data areas to meet known scenarios and can dynamically create new data areas to meet future scenario needs.

[0061] S103, when receiving a cache read request, reading data from the cache area according to the data area number and status information of each data area in the cache area;

[0062] Specifically, the above step S103 can be implemented as follows: reading data from the corresponding data area in the cache area according to the data area number and data type, and updating the timestamp in the data area after the reading is successful.

[0063] When reading data, the application obtains the corresponding data according to the data area number and data type, distinguishes between single reading and multiple reading, and updates the timestamp in the data area for each reading. The data reading process also includes checking the data type and validity, and determining the length of the cached data.

[0064] S104: Manage the cache area according to the status information of each data area in the cache area.

[0065] Specifically, the above step S104 can be implemented as follows:

[0066] For single-use data in a data area, the data area is cleared after reading, and the timestamp in the data area is updated;

[0067] For the data in the data area that is used multiple times, an available number is set. When the available number is zero, the data area is cleared and the timestamp in the data area is updated;

[0068] For each data area, determine the difference between the timestamp in the data area and the current time. If the difference exceeds the preset time range, clear the data area and update the timestamp in the data area. For example, for long-term valid data, wait until the invalid mark is shown before clearing the data, and update the timestamp after clearing.

[0069] If the data area is a new data area created by applying for new memory and is not occupied, the difference between the timestamp in the new data area and the current time is determined, and if the difference exceeds the preset time range, the new data area is released. It can be seen that this application can release memory in time.

[0070] The software cache management method provided in the embodiment of the present application creates a cache including multiple fixed-size data areas according to the received cache creation request, and records the data area number and status information of each data area; when receiving a write cache request, writes data into the cache according to the status information of each data area in the cache; when receiving a read cache request, reads data from the cache according to the data area number and status information of each data area in the cache; manages the cache according to the status information of each data area in the cache; wherein the status information includes the usage status, the data type and data length of the stored data, and the timestamp, and the data type includes single-use data, multiple-use data, and long-term valid data. Compared with the prior art, the present application pre-opens a cache data area, distinguishes the timing of clearing the data area and releasing the memory, avoids frequent memory application, can release the memory in time, and reduces the occupation of resources.

[0071] In the above embodiment, a method for managing a software cache is provided. Correspondingly, the present application also provides a device for managing a software cache. The device for managing a software cache provided in the embodiment of the present application can implement the above method for managing a software cache. The device for managing a software cache can be implemented by software, hardware, or a combination of software and hardware. For example, the device for managing a software cache can include integrated or separate functional modules or units to perform the corresponding steps in the above methods. Please refer to Figure 3 As shown, the software cache management device 10 of the present application includes:

[0072] The creation module 101 is used to create a cache area including multiple fixed-size data areas according to the received cache area creation request, and record the data area number and status information of each data area;

[0073] A writing module 102, configured to write data into the cache area according to the status information of each data area in the cache area when receiving a write cache request;

[0074] The reading module 103 is used to read data from the cache area according to the data area number and status information of each data area in the cache area when receiving a cache read request;

[0075] A management module 104, configured to manage the cache area according to the status information of each data area in the cache area;

[0076] The state information includes the usage state, the data type and data length of the stored data, and a timestamp. The data type includes single-use data, multiple-use data, and long-term valid data.

[0077] In a possible implementation, the writing module 102 is specifically configured to:

[0078] Determining whether there is an available data area in the cache area according to the status information of each data area in the cache area;

[0079] If there is no available data area, apply for a new memory as a new data area, write the data into the new data area, and record the data area number and status information of the new data area;

[0080] If there is currently an available data area, the data is written to the available data area, and the timestamp in the data area is updated after the writing is successful.

[0081] In a possible implementation, the reading module 103 is specifically configured to:

[0082] Data is read from the corresponding data area in the buffer area according to the data area number and data type, and the timestamp in the data area is updated after the reading is successful.

[0083] In a possible implementation, the management module 104 is specifically configured to:

[0084] For single-use data in a data area, the data area is cleared after reading, and the timestamp in the data area is updated;

[0085] For the data in the data area that is used multiple times, an available number is set. When the available number is zero, the data area is cleared and the timestamp in the data area is updated;

[0086] For each data area, determine the difference between the timestamp in the data area and the current time. If the difference exceeds a preset time range, clear the data area and update the timestamp in the data area.

[0087] If the data area is a new data area created by applying for new memory and is not occupied, the difference between the timestamp in the new data area and the current time is determined. If the difference exceeds a preset time range, the new data area is released.

[0088] The software cache management device provided in the embodiment of the present application and the software cache management method provided in the embodiment of the present application are based on the same inventive concept and have the same beneficial effects as the methods adopted, run or implemented therein.

[0089] An embodiment of the present application also provides an electronic device corresponding to the method provided in the above embodiment, and the electronic device can be an electronic device used for a client, such as a mobile phone, a laptop computer, a tablet computer, a desktop computer, etc., to execute the above-mentioned software cache management method.

[0090] Please refer to Figure 4 , which shows a schematic diagram of an electronic device provided by some embodiments of the present application. Figure 4 As shown, the electronic device 20 includes: a processor 200, a memory 201, a bus 202 and a communication interface 203, and the processor 200, the communication interface 203 and the memory 201 are connected via the bus 202; the memory 201 stores a computer program that can be run on the processor 200, and when the processor 200 runs the computer program, it executes the software cache management method provided in any of the aforementioned embodiments of the present application.

[0091] The memory 201 may include a high-speed random access memory (RAM), and may also include a non-volatile memory, such as at least one disk memory. The communication connection between the system network element and at least one other network element is realized through at least one communication interface 203 (which may be wired or wireless), and the Internet, wide area network, local area network, metropolitan area network, etc. may be used.

[0092] The bus 202 may be an ISA bus, a PCI bus, or an EISA bus, etc. The bus may be divided into an address bus, a data bus, a control bus, etc. The memory 201 is used to store programs, and the processor 200 executes the programs after receiving execution instructions. The software cache management method disclosed in any implementation of the embodiment of the present application may be applied to the processor 200, or implemented by the processor 200.

[0093] The processor 200 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the hardware integrated logic circuit or software instructions in the processor 200. The above processor 200 can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a readily available programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The methods, steps and logic block diagrams disclosed in the embodiments of the present application can be implemented or executed. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc. The steps of the method disclosed in the embodiments of the present application can be directly embodied as a hardware decoding processor to be executed, or the hardware and software modules in the decoding processor can be executed. The software module can be located in a mature storage medium in the field such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory or an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory 201, and the processor 200 reads the information in the memory 201 and completes the steps of the above method in combination with its hardware.

[0094] The electronic device provided in the embodiment of the present application and the software cache management method provided in the embodiment of the present application are based on the same inventive concept and have the same beneficial effects as the methods adopted, run or implemented therein.

[0095] An embodiment of the present application also provides a computer-readable storage medium corresponding to the software cache management method provided in the aforementioned embodiment, on which a computer program (i.e., a program product) is stored. When the computer program is run by a processor, it will execute the software cache management method provided in any of the aforementioned embodiments.

[0096] It should be noted that examples of the computer-readable storage medium may also include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other optical or magnetic storage media, which are not listed here one by one.

[0097] The computer-readable storage medium provided in the above-mentioned embodiments of the present application and the software cache management method provided in the embodiments of the present application are based on the same inventive concept and have the same beneficial effects as the methods adopted, run or implemented by the application programs stored therein.

[0098] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein by equivalents. These modifications or replacements do not deviate the essence of the corresponding technical solutions from the scope of the technical solutions of the embodiments of the present application, and they should all be included in the scope of the claims and specification of the present application.

Claims

1. A method for managing a software cache, characterized in that: include: Creating a cache area including a plurality of fixed-size data areas according to the received cache area creation request, and recording a data area number and status information of each of the data areas; When receiving a write cache request, writing data into the cache area according to the status information of each data area in the cache area; When receiving a cache read request, reading data from the cache area according to the data area number and status information of each data area in the cache area; Managing the cache area according to the status information of each data area in the cache area; The state information includes the usage state, the data type and data length of the stored data, and a timestamp. The data type includes single-use data, multiple-use data, and long-term valid data.

2. The method according to claim 1, characterized in that The step of writing data into the cache area according to the status information of each data area in the cache area comprises: Determining whether there is an available data area in the cache area according to the status information of each data area in the cache area; If there is no available data area, apply for a new memory as a new data area, write the data into the new data area, and record the data area number and status information of the new data area; If there is currently an available data area, the data is written to the available data area, and the timestamp in the data area is updated after the writing is successful.

3. The method according to claim 1, characterized in that The step of reading data from the cache area according to the data area number and status information of each data area in the cache area comprises: Data is read from the corresponding data area in the buffer area according to the data area number and data type, and the timestamp in the data area is updated after the reading is successful.

4. The method according to claim 1, characterized in that The managing the cache area according to the status information of each data area in the cache area comprises: For single-use data in a data area, the data area is cleared after reading, and the timestamp in the data area is updated; For the data in the data area that is used multiple times, an available number is set. When the available number is zero, the data area is cleared and the timestamp in the data area is updated; For each data area, determine the difference between the timestamp in the data area and the current time. If the difference exceeds a preset time range, clear the data area and update the timestamp in the data area. If the data area is a new data area created by applying for new memory and is not occupied, the difference between the timestamp in the new data area and the current time is determined. If the difference exceeds a preset time range, the new data area is released.

5. A software cache management device, characterized in that: include: A creation module, used to create a cache area including a plurality of fixed-size data areas according to a received cache area creation request, and record a data area number and status information of each of the data areas; A writing module, configured to write data into the cache area according to the status information of each data area in the cache area when receiving a write cache request; A reading module, configured to read data from the cache area according to the data area number and status information of each data area in the cache area when receiving a cache read request; A management module, used for managing the cache area according to the status information of each data area in the cache area; The state information includes the usage state, the data type and data length of the stored data, and a timestamp. The data type includes single-use data, multiple-use data, and long-term valid data.

6. The device according to claim 5, characterized in that The writing module is specifically used for: Determining whether there is an available data area in the cache area according to the status information of each data area in the cache area; If there is no available data area, apply for a new memory as a new data area, write the data into the new data area, and record the data area number and status information of the new data area; If there is currently an available data area, the data is written to the available data area, and the timestamp in the data area is updated after the writing is successful.

7. The device according to claim 5, characterized in that The reading module is specifically used for: Data is read from the corresponding data area in the buffer area according to the data area number and data type, and the timestamp in the data area is updated after the reading is successful.

8. The device according to claim 5, characterized in that The management module is specifically used for: For single-use data in a data area, the data area is cleared after reading, and the timestamp in the data area is updated; For the data in the data area that is used multiple times, an available number is set. When the available number is zero, the data area is cleared and the timestamp in the data area is updated; For each data area, determine the difference between the timestamp in the data area and the current time. If the difference exceeds a preset time range, clear the data area and update the timestamp in the data area. If the data area is a new data area created by applying for new memory and is not occupied, the difference between the timestamp in the new data area and the current time is determined. If the difference exceeds a preset time range, the new data area is released.

9. An electronic device, comprising: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the method according to any one of claims 1 to 4 when executing the computer program.

10. A computer-readable storage medium, characterized in that: Computer-readable instructions are stored thereon, and the computer-readable instructions can be executed by a processor to implement the method according to any one of claims 1 to 4.