Resource reading method and device, electronic equipment and storage medium

By using memory cache to read resource files with compressed file paths in computer applications, the problem of local storage space occupation is solved, and resource reading efficiency and user experience are improved.

CN120492418APending Publication Date: 2025-08-15GUANGZHOU HUYA TECH CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202510627871.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-05-15
Publication Date
2025-08-15

AI Technical Summary

Technical Problem

In the resource deployment and dynamic loading scenarios of computer applications, the prior art causes local storage space to occupy a large amount of space after decompression of resource files, affecting user experience and resource deployment efficiency.

Method used

The target file path is converted by preset compressed file fields, the compressed file path is generated, and resource files are read in the memory cache, taking advantage of the efficiency of memory cache to reduce the use of local storage space.

Benefits of technology

It improves the efficiency of resource reading, reduces the use of local storage space, and improves user experience and resource deployment efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120492418A_ABST
    Figure CN120492418A_ABST
Patent Text Reader

Abstract

The invention relates to the field of computer data processing, in particular to a resource reading method and device, electronic equipment and a storage medium, and the method comprises the steps: carrying out the path conversion of a target file path through a preset compressed file field, and obtaining a compressed file path; the target file path is generated according to a target resource to be read; the compressed file path represents a file path of a compressed file package containing the target resource; reading a corresponding resource file in a memory cache according to the compressed file path to serve as a target resource; the resource file is decompressed to the memory cache from a compressed file package corresponding to the compressed file path; the memory cache is a cache region arranged in a memory space. Compared with the prior art, the resource reading efficiency is improved by decompressing the resource file of the compressed file package to the memory cache and utilizing the high efficiency of the memory cache for file reading.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer data processing, and more specifically, to a resource reading method, device, electronic device and storage medium. Background Art

[0002] In resource deployment and dynamic loading scenarios for computer applications, to reduce the size of the program's local deployment package, some non-core resource files are often categorized by functional module, compressed, and uploaded to a CDN (Content Delivery Network). After the program starts, based on user operation scenarios or pre-set policies, the required resource compressed packages are pulled from the CDN and decompressed to local storage for subsequent use. Once these compressed resource packages are decompressed to local storage, they occupy a significant amount of local storage space, causing the local storage space to be continuously compressed. Summary of the Invention

[0003] The present invention provides a resource reading method, device, electronic device and storage medium, which effectively reduce the local storage space occupied by resources during the process of calling and reading.

[0004] According to a first aspect of the present application, a resource reading method is provided, the method comprising: According to the preset compressed file field, the target file path is converted to obtain a compressed file path; the target file path is generated according to the target resource to be read; the compressed file path represents the file path of the compressed file package containing the target resource; The corresponding resource file is read from the memory cache as the target resource according to the compressed file path; the resource file is decompressed from the compressed file package corresponding to the compressed file path to the memory cache.

[0005] Optionally, performing path conversion on the target file path according to the preset compressed file field to obtain the compressed file path includes: According to the preset compressed file field, query in the target file path to obtain the corresponding path file field; According to the preset compressed file type, the corresponding compressed file suffix is added after the path file field to obtain a replacement file field; The path file field in the target file path is replaced by the replacement file field to obtain the compressed file path.

[0006] Optionally, reading a corresponding resource file from a memory cache as a target resource according to the compressed file path includes: A memory mapping table is queried according to the compressed file path to obtain a query result, and a corresponding resource file is read from the memory cache as a target resource according to the query result; wherein the memory mapping table records the mapping relationship between the resource file in the memory cache and the compressed file path.

[0007] Optionally, querying a memory mapping table according to the compressed file path to obtain a query result, and reading a corresponding resource file from the memory cache as a target resource according to the query result, includes: The memory mapping table is queried according to the compressed file path. If the corresponding resource file exists in the memory cache, it is read as the target resource; otherwise, the corresponding compressed file package is obtained from the local storage space, its resource file is decompressed into the memory cache, and then read as the target resource, and the memory mapping table is updated.

[0008] Optionally, querying a memory mapping table according to the compressed file path to obtain a query result, and reading a corresponding resource file from the memory cache as a target resource according to the query result, includes: According to the compressed file path, the corresponding compressed file package is queried in the local storage space. If the corresponding compressed file package exists in the local storage space, the memory mapping table is queried according to the compressed file path to obtain the query result, and the corresponding resource file is read from the memory cache as the target resource according to the query result.

[0009] Optionally, obtaining a corresponding compressed file package according to the compressed file path includes: According to a preset network resource mapping table, the network resource address of the corresponding compressed file package is obtained through the compressed file path; the network resource mapping table records the mapping relationship between the compressed file package and the network resource address; Download the corresponding compressed file package to the local storage space according to the network resource address.

[0010] Optionally, the resource files stored in the memory cache are periodically cleared according to a preset clearing policy.

[0011] According to a second aspect of the present application, a resource reading device is provided, the device comprising: A path replacement module is used to perform path conversion on the target file path according to a preset compressed file field to obtain a compressed file path; the target file path is generated according to the target resource to be read; the compressed file path represents the file path of the compressed file package containing the target resource; The resource reading module is used to read the corresponding resource file in the memory cache as the target resource according to the compressed file path; the resource file is decompressed from the compressed file package corresponding to the compressed file path to the memory cache.

[0012] According to a third aspect of the present application, an electronic device is provided, including: a memory for storing one or more computer programs; The processor implements the resource reading method described in the first aspect when the one or more computer programs are executed by the processor.

[0013] According to a fourth aspect of the present application, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the resource reading method described in the first aspect when executed.

[0014] Based on any one of the above aspects, the resource reading method, device, electronic device and computer storage medium provided in the embodiments of the present application, by utilizing a specific compressed file field, perform path conversion on the target file path of the resource to be read to obtain a compressed file path. After obtaining the compressed file path, it can be read from the memory cache according to the compressed file path to read the resource file pre-decompressed in the memory cache. Compared with obtaining files from the local storage space, the reading speed of obtaining resource files from the memory cache is faster; at the same time, since the resource file is directly decompressed into the memory cache and will not be decompressed in the local storage space, it can effectively reduce the occupation of the local resource space by the resource file, thereby effectively improving the utilization rate of the local resource space. BRIEF DESCRIPTION OF THE DRAWINGS

[0015] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.

[0016] Figure 1 This is a schematic diagram of an application scenario of the resource reading method provided in this embodiment.

[0017] Figure 2 This is a flowchart of the resource reading method provided in this embodiment.

[0018] Figure 3 A schematic diagram of the steps for obtaining the compressed file path provided in this embodiment.

[0019] Figure 4 Schematic diagram of the steps for obtaining target resources provided in this embodiment Figure 1 .

[0020] Figure 5 Schematic diagram of the steps for obtaining target resources provided in this embodiment Figure 2 .

[0021] Figure 6 A schematic diagram of the steps for obtaining a compressed file package provided in this embodiment.

[0022] Figure 7 This is a schematic diagram of the functional modules of the resource reading device provided in this embodiment.

[0023] Figure 8 A schematic structural diagram of an electronic device provided in this embodiment. DETAILED DESCRIPTION

[0024] The figures in this application are for illustrative purposes only and are not to be construed as limiting the present application. To better illustrate the following embodiments, some components in the figures may be omitted, enlarged, or reduced in size, and do not represent actual product dimensions. Those skilled in the art will appreciate that some well-known structures and their descriptions may be omitted from the figures.

[0025] In order to enable those skilled in the art to better understand the present invention, the following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments in the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts should fall within the scope of protection of this application.

[0026] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequential order. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in a sequence other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0027] In resource deployment and dynamic loading scenarios for computer applications, such as application installation or update scenarios, non-core resources (such as images, audio and video, configuration files, etc.) are typically not built directly into the deployment package to reduce the size of the program's local deployment package. Instead, these non-core resource files are categorized by functional module, compressed, and uploaded to the CDN network. After the program starts, based on the user's operation scenario or preset policies, the required resource compressed packages are pulled from the CDN and decompressed to local storage for subsequent use. After these resource compressed packages are decompressed to local storage, they, on the one hand, take up a large amount of local storage space, especially on devices with limited local storage space, such as mobile phones. This causes the local storage space to be continuously compressed, affecting the user experience. On the other hand, the local storage space is relatively slow to decompress and read files. When a large number of resources need to be decompressed to or read from the local storage, this seriously reduces the efficiency of resource deployment.

[0028] This embodiment provides a technical solution that can solve the above-mentioned problem. The specific implementation methods of this application are described in detail below with reference to the accompanying drawings.

[0029] For example, the following is a schematic diagram of an application scenario of a resource reading method provided in an embodiment of the present application. Figure 1 As shown, the application scenario at least includes a server 100 and a terminal 200 that can communicate with the server 100. It is understandable that the server 100 can be an independent electronic device or a cluster of multiple electronic devices; the terminal 200 can be a smart phone terminal, a personal computer, a tablet computer, a car terminal, etc., but is not limited thereto.

[0030] In one practicable manner, the server 100 and the terminal 200 may respectively execute the resource reading method provided in the embodiment of the present application, or, optionally, the resource reading method provided in the embodiment of the present application is partially executed in the server 100 and partially executed in the terminal 200.

[0031] like Figure 2 As shown, this embodiment provides a resource reading method, which may include the following steps: S1: According to the preset compressed file field, the target file path is converted to obtain the compressed file path; It is understandable that in existing technical solutions, for an application to be deployed, the application will obtain the target resources required for this round of deployment. These target resources are usually stored in a file specified by the application. When the application is deployed, it is read from the specified file. Therefore, the target file path can be generated based on the target resource to be read, including: obtaining the location information of the target resource and a specified file directory, splicing the specified file directory and the location information to generate the target file path.

[0032] Understandably, applications typically store resources in a designated file. However, to facilitate resource classification and organization, this designated file is typically not set as the lowest-level file where the target resource is stored. Instead, a common path is set for all resources. The specific storage file for each resource can be set in the resource's location information, allowing resources of the same type to be grouped together.

[0033] For example, when the application is deployed, the location information of the required resources is "folder / file.txt", and the specified file directory is "user / resource / ", then the generated target file path can be "user / resource / folder / file.txt"; it can be understood that the resource files of the application are stored in "user / resource / ", and the resources of the folder class are saved in the corresponding "folder" file.

[0034] However, the above situation is an existing technical solution. As mentioned above, if the resource is read through the target file path of the local storage space, it will not only reduce the reading efficiency of the resource, but also occupy the local storage space. Therefore, in order to avoid this situation, this embodiment does not use the target file path of the local storage space to read the resource, but obtains the corresponding resource through the compressed file path. The compressed file path represents the file path of the compressed file package containing the target resource. For example, if the compressed file package corresponding to the resource "folder / file.txt" is "folder.zip", and the compressed file package is in the file directory "user / resource / ", then the corresponding compressed file path can be expressed as "user / resource / folder.zip / file.txt".

[0035] Specifically, in this embodiment, Figure 3 As shown, obtaining the compressed file path may include the following steps: S11: According to the preset compressed file field, query in the target file path to obtain the corresponding path file field; In this embodiment, the compressed file field may include multiple entries, each of which may include the name of the compressed file package corresponding to the resource file and the file name of the corresponding resource file; the path file field is a field that includes the name of the compressed file package. It is understandable that for an application, the name or path of the resource required when the application is deployed can be written into the application through programming or other means, so that the application can effectively obtain the corresponding resources when it is deployed. Therefore, in this embodiment, the same or similar method can be used to write multiple compressed file fields into the application, so that the application can query the path file field based on the compressed file field when it is deployed.

[0036] For example, if the target file path is "user / resource / folder / file.txt", the name of the compressed file package contained in the compressed file field is "folder", and the file name of the corresponding resource file is "file". Therefore, the path file field queried in the target file path through the compressed file field is "folder".

[0037] S12: According to the preset compressed file type, add the corresponding compressed file suffix after the path file field to obtain a replacement file field; It is understandable that in order to obtain the compressed file path in the above example, the path file field in the target file path needs to be replaced accordingly, that is, the corresponding compressed file suffix name is added after the obtained path file field. Different compressed file packages have different corresponding compressed file suffix names. Therefore, in this embodiment, it is necessary to preset the compressed file type of the application to ensure that the replacement file field obtained by replacing it according to the preset compressed file type can be effectively recognized.

[0038] Taking the above-mentioned case where the path file field is "folder" as an example, assuming that the preset compressed file type is "zip", the obtained replacement file field is "folder.zip".

[0039] The compressed file types may include but are not limited to zip, rar, 7z and other compressed file types.

[0040] S13: Replace the path file field in the target file path with the replacement file field to obtain the compressed file path.

[0041] Specifically, taking the above-mentioned target file path "user / resource / folder / file.txt" as an example, and based on the example in step S12, the replacement file field obtained is "folder.zip", and the replacement file field "folder.zip" is used to replace the path file field "folder" to obtain the compressed file path "user / resource / folder.zip / file.txt".

[0042] S2: Read the corresponding resource file in the memory cache according to the compressed file path as the target resource; It will be appreciated that in this embodiment, the resource file is decompressed from the compressed file package corresponding to the compressed file path and stored in the memory cache. Therefore, it is necessary to query the stored resource file in the memory cache to confirm that the corresponding resource file has been stored in the memory cache, and then read the corresponding resource file from the memory cache to implement application deployment.

[0043] In this embodiment, the memory cache is a cache area set in the memory space. The memory space may mainly include internal memory such as RAM (Random Access Memory) and SRAM (Static RAM), and can directly interact with the CPU (Central Processing Unit) in the computer. Therefore, resource files decompressed into the memory cache can be quickly read by the CPU, thereby effectively improving the efficiency of reading resource files. At the same time, decompressing resource files into the memory space increases the time consumption. To avoid frequent access to resource files that results in excessive time consumption, this embodiment sets a cache area in the memory space, namely the memory cache, to temporarily store resource files, thereby reducing the operation of decompressing resource files into the memory cache.

[0044] Specifically, the resource file may be obtained by: querying a memory mapping table according to the compressed file path to obtain a query result, and reading a corresponding resource file from the memory cache as a target resource according to the query result; In this embodiment, the memory mapping table records the mapping relationship between resource files and compressed file paths in the memory cache. Specifically, when a resource file is decompressed from a compressed file package into the memory cache, the decompressed resource file and the compressed file path of the corresponding compressed file package are recorded in the memory mapping table to form the mapping relationship.

[0045] In one embodiment, the memory mapping table can be configured as a data storage format such as a database or a data file, and stored in a local storage space for use by the application when deployed. It is understood that the memory mapping table can be implemented using a data storage format of the prior art, and the configuration format of the memory mapping table is not further limited herein.

[0046] In one embodiment, querying a memory mapping table according to the compressed file path to obtain a query result, and reading a corresponding resource file from the memory cache as a target resource according to the query result may specifically include: The memory mapping table is queried according to the compressed file path. If the corresponding resource file exists in the memory cache, it is read as the target resource; otherwise, the corresponding compressed file package is obtained from the local storage space, its resource file is decompressed into the memory cache, and then read as the target resource, and the memory mapping table is updated.

[0047] Specifically, such as Figure 4 As shown, the reading of the resource file may specifically include the following steps: A1: Query the memory mapping table according to the compressed file path to determine whether the corresponding resource file is cached in the memory cache: In this embodiment, the memory mapping table reflects the mapping relationship between the resource file and the compressed file path. Therefore, the memory mapping table is queried according to the compressed file path. If the corresponding mapping can be found in the memory mapping table, it means that the corresponding resource file has been decompressed into the memory cache. Otherwise, it means that the corresponding resource file has not been decompressed into the memory cache.

[0048] A2: If yes, read the corresponding resource file from the memory cache as the target resource; As mentioned above, if the corresponding resource file can be found in the memory cache, the resource file can be directly read to implement the deployment of the application without loading the resource file into the local storage space, thereby improving the reading efficiency of the resource file.

[0049] A3: If not, search the local storage space for the corresponding compressed file package according to the compressed file path; It is understandable that if the corresponding resource file cannot be found in the memory cache, it means that the resource file in the corresponding compressed file package has not been decompressed into the memory cache. In this case, it is necessary to search the local storage space for the corresponding compressed file package to decompress the resource file in the compressed file package into the memory cache.

[0050] A4: If a corresponding compressed file package is found in the local storage space, the resource file in the compressed file package is decompressed into a memory cache, the resource file is read from the memory cache as the target resource, and a mapping relationship between the compressed file path and the resource file decompressed into the memory cache is recorded in the memory mapping table; A5: If the corresponding compressed file package is not found in the local storage space, the corresponding compressed file package is obtained according to the compressed file path, the resource file in the obtained compressed file package is decompressed into the memory cache, the resource file is read from the memory cache as the target resource, and the mapping relationship between the compressed file path and the resource file decompressed into the memory cache is recorded in the memory mapping table.

[0051] In this embodiment, if the corresponding resource file is not found in the memory cache and the corresponding compressed file package is not found in the local storage space, it means that there is no relevant compressed file package locally and the corresponding compressed file package needs to be obtained or retrieved. Since the corresponding compressed file package does not exist locally, the corresponding compressed file package needs to be downloaded from the cloud or server.

[0052] Specifically, such as Figure 6 As shown, obtaining the compressed file package may include the following steps: C1: According to a preset network resource mapping table, obtain the network resource address of the corresponding compressed file package through the compressed file path; C2: Download the corresponding compressed file package to the local storage space according to the network resource address.

[0053] In this embodiment, the network resource mapping table records the mapping relationship between the compressed file package and the network resource address; specifically, the network resource mapping table can be set to a data storage form such as a database, a data file, etc.

[0054] The network resource mapping table can be constructed specifically by configuring corresponding files on the cloud or server side according to the resource files required during the development of the corresponding application, and mapping the network resource address of the corresponding resource file when it is deployed on the cloud or server side, such as the URL (Uniform Resource Locator) address, with the resource file and writing it into the network resource mapping table.

[0055] Therefore, the resource file to be extracted can be determined by the compressed file path, and the corresponding network resource address can be obtained by querying the network resource mapping table. Then, based on the network resource address, the compressed file package of the corresponding resource file can be downloaded from the cloud or server to the local storage space to be decompressed into the memory cache. The compressed file package is downloaded to a designated folder in the local storage space to obtain the corresponding path.

[0056] It can be understood that in this embodiment, by first searching the memory cache, directly reading the resource file according to the search results, or decompressing the resource file from the compressed package file in the local storage space to the memory cache for reading, if the resource file stored in the memory cache needs to be read frequently, the resource file can be read more quickly.

[0057] In another embodiment, querying a memory mapping table according to the compressed file path to obtain a query result, and reading a corresponding resource file from the memory cache as a target resource according to the query result may specifically include: According to the compressed file path, the corresponding compressed file package is queried in the local storage space. If the corresponding compressed file package exists in the local storage space, the memory mapping table is queried according to the compressed file path to obtain the query result, and the corresponding resource file is read from the memory cache as the target resource according to the query result.

[0058] Specifically, such as Figure 5 As shown, the reading of the resource file may further include the following steps: B1: Query the corresponding compressed file package in the local storage space according to the compressed file path: B2: If the corresponding compressed file package is found in the local storage space, the memory mapping table is searched according to the compressed file path to determine whether the corresponding resource file is cached in the memory cache; B3: If yes, read the corresponding resource file from the memory cache as the target resource; B4: If not, decompress the resource file in the corresponding compressed file package into a memory cache, read the resource file from the memory cache as the target resource, and record the mapping relationship between the compressed file path and the resource file decompressed into the memory cache in the memory mapping table; B5: If the corresponding compressed file package is not found in the local storage space, the corresponding compressed file package is obtained according to the compressed file path, the resource file in the obtained compressed file package is decompressed into the memory cache, the resource file is read from the memory cache as the target resource, and the mapping relationship between the compressed file path and the resource file decompressed into the memory cache is recorded in the memory mapping table.

[0059] Steps B1-B5 of this embodiment are similar to the above steps A1-A5. The specific implementation of each step of this embodiment can refer to the description of the above steps A1-A5 and will not be further elaborated here.

[0060] The main difference between steps B1-B5 in this embodiment and steps A1-A5 described above is that in this embodiment, the compressed file package is first queried. By first querying the compressed file package, the application can first determine whether there is a compressed file package corresponding to the resource file, and then decompress the compressed file package into the memory cache. In this way, for resource files that do not need to be read frequently from the memory cache, more accurate search and decompression can be achieved. When the corresponding resource file needs to be read, the resource file is decompressed into the memory cache, avoiding excessive decompression of files into the memory cache and causing the memory cache to be occupied. In this embodiment, one of the above two embodiments can be selected for implementation according to actual needs.

[0061] It should be noted that the resource files described in this embodiment mainly refer to files that need to be decompressed into the memory cache and read by the application. When the compressed file package contains multiple files, only the files that need to be read are decompressed into the memory cache as resource files and recorded in the memory mapping table.

[0062] As is understandable, the memory cache itself has a relatively small capacity. Excessively decompressing resource files into the memory cache can result in a high file occupancy rate in the memory cache, thereby impacting the efficiency of data read from the memory cache. Therefore, in this embodiment, the resource files stored in the memory cache are periodically cleared according to a preset clearing policy.

[0063] In one embodiment, the clearing policy can be configured to clear resource files stored in the memory cache based on the time the resource files were decompressed into the memory cache and the frequency of reading. For example, when the cache time of the resource files in the memory cache exceeds a preset cache duration threshold, and the frequency of reading the resource files is lower than a preset read count threshold, the corresponding resource files are cleared from the memory cache to ensure that there is sufficient space in the memory cache, thereby ensuring the reading efficiency of the resource files.

[0064] It can be understood that in this embodiment, since the memory mapping table reflects the mapping relationship between resource files and compressed file paths, through the memory mapping table, not only resource files in multiple compressed file packages can be obtained, but also multiple resource files in the same compressed file package can be obtained.

[0065] In one embodiment, after the compressed file package decompresses the resource file into the memory cache, a corresponding resource name can be set for the resource file. The resource name is mainly used to represent the resource file in the memory cache, and then the correspondence between the compressed file path-resource name-resource file is realized through the memory mapping table.

[0066] In a specific example, assume that the compressed file package "folder.zip" contains the "file.txt" file and the "file2.txt" file, and the corresponding compressed file paths are "user / resource / folder.zip / file.txt" and "user / resource / folder.zip / file2.txt" respectively. Both files need to be read by the application. According to the two compressed file paths, the corresponding compressed file package is found in the corresponding local storage space, and the two files in the compressed file package are decompressed as resource files to the memory cache, "file.txt" is set as data1 in the memory cache, and "file2.txt" is set as data2 in the memory cache. The above two corresponding compressed file paths and the corresponding resource files are recorded in the memory mapping table respectively. When the target resource needs to be read, the target file path of the target resource is obtained and converted into the corresponding compressed file path. Then, the corresponding resource file is obtained from the memory cache by querying the memory mapping table, and the corresponding resource file is read according to the set resource name.

[0067] In this embodiment, it is understandable that it is not necessary to decompress the resource file into the memory cache. The corresponding file in the compressed file package can also be decompressed into the local storage space in a conventional manner. When the target resource needs to be obtained, the corresponding target resource is directly read in the local storage space according to the target file path of the target resource. Specifically, the compressed file package decompresses the file into the memory cache or the local storage space, which can be set according to actual needs. For example, as in the above steps A4, A5, B4 and B5, for larger files, you can choose to decompress the file into the local storage space to avoid occupying a large space in the memory cache. For smaller files, you can choose to decompress the file into the memory cache to improve the reading efficiency of the resource file.

[0068] In this embodiment, a file access adapter can be configured for the application. This adapter hides the details and differences of the compressed file package from the application's business layer and encapsulates the method for decompressing the compressed file package into the memory cache, allowing the application to read the corresponding resource file from the memory cache just as it reads files from local storage. The file access adapter is configured with policies for the two decompression schemes described above.

[0069] In this embodiment, since the resource file is read from the memory cache, compared with reading the resources directly from the local storage space, it can effectively improve the efficiency of resource reading, thereby improving the efficiency of application deployment; at the same time, the files in the compressed file package can be decompressed into the memory cache, reducing the space occupied by the local storage space.

[0070] like Figure 7 As shown, the embodiment of the present application further provides a resource reading device. Optionally, the resource reading device may include: The path replacement module 11 is used to perform path conversion on the target file path according to the preset compressed file field to obtain the compressed file path; In this embodiment, the path replacement module 11 can be used to perform Figure 2 As shown in step S1, for the detailed description of the path replacement module 11, reference may be made to the description of step S1.

[0071] The resource reading module 12 is used to read the corresponding resource file in the memory cache as the target resource according to the compressed file path; In this embodiment, the resource reading module 12 can be used to execute Figure 2 As shown in step S2, for a detailed description of the resource reading module 12, reference may be made to the description of step S2.

[0072] In one embodiment, the resource reading device may further include a resource downloading module 13, and the resource downloading module 13 is configured to download a compressed file package corresponding to the resource file from the cloud or the server to a local storage space.

[0073] In this embodiment, the resource download module 13 can be used to execute Figure 6 Regarding steps C1-C2 shown, for a detailed description of the resource download module 13 , reference may be made to the description of steps C1-C2 .

[0074] It can be understood that the above-mentioned device embodiments and the above-mentioned method embodiments can correspond to each other, and similar descriptions of the device embodiments can refer to the method embodiments. To avoid repetition, they will not be described here. A resource reading device provided in an embodiment of the present application can execute a resource reading method provided in any embodiment of the present application, and has functional modules and beneficial effects corresponding to the execution method. The functional modules of the resource reading device can be implemented in the form of hardware, can be implemented by instructions in the form of software, and can also be implemented by a combination of hardware and software modules.

[0075] Specifically, each step of the method embodiment of the present application can be completed by the hardware integrated logic circuit and / or software instructions in the processor. The steps of the resource reading method in combination with the embodiment of the present application can be directly embodied as being executed by the hardware encoding processor, or being executed by a combination of hardware and software modules in the encoding processor. Optionally, the software module can be located in a random access memory, a read-only memory, a programmable read-only memory, a flash memory, an electrically erasable programmable memory, a register, or other storage media. The storage medium is located in the memory, and the processor reads the information in the memory and completes the steps in the above method embodiment in combination with its hardware.

[0076] The embodiment of the present application provides an electronic device 20, the structure of which is as follows: Figure 8 The electronic device 20 may be Figure 1 The server 100 or the terminal 200 is shown.

[0077] like Figure 8 As shown, the electronic device 20 includes a memory 21, a processor 22, a communication module 23 and an input / output interface 24, etc. Optionally, the memory 21, the processor 22, the communication module 23 and the input / output interface 24 can be connected and communicated through a bus 25.

[0078] The memory 21 is used to store one or more computer programs and transmit the codes of the computer programs to the processor 22; when the one or more computer programs are executed by the processor 22, the resource reading method in the embodiment of the present application is implemented.

[0079] Optionally, the electronic device 20 can be connected to a network via a communication module 23 to communicate with other devices, such as a terminal or a server, via the network to achieve data exchange. The electronic device 20 can be various forms of digital computers, such as desktop computers, servers, workstations, mainframe computers, or other types of computers. The electronic device 20 can also be various forms of mobile terminals, such as smartphones, tablet computers, wearable devices (such as helmets, glasses, watches, etc.), and other similar mobile terminals.

[0080] Optionally, the electronic device 20 can be connected to the required input / output devices, such as a keyboard, a display device, etc., through the input / output interface 24. The electronic device 20 itself can have a display device, and can also be connected to other external display devices through the input / output interface 24. Optionally, a storage device, such as a hard disk, can also be connected through the input / output interface 24, so that data in the electronic device 20 can be stored in the storage device, or data in the storage device can be read, and data in the storage device can also be stored in the memory 21. It can be understood that the input / output interface 24 can be a wired interface or a wireless interface. Depending on the actual application scenario, the device connected to the input / output interface 24 can be a component of the electronic device 20, or it can be an external device connected to the electronic device 20 when needed.

[0081] Optionally, the memory 21 can be a volatile memory and / or a non-volatile memory, the volatile memory can be a random access memory, etc., and the non-volatile memory can be a read-only memory, a programmable read-only memory, an erasable programmable read-only memory, an electrically erasable programmable read-only memory or a flash memory, etc.

[0082] Optionally, the computer program stored in the processor 22 may be divided into one or more modules, which are stored in the memory 21 and executed by the processor 22 to perform the method provided in the embodiment. The one or more modules may be a series of computer program instruction segments capable of performing specific functions, and the computer program instruction segments are used to describe the execution process of the computer program in the electronic device 20.

[0083] Optionally, the processor 22 may be any general-purpose and / or specialized processing component with processing and computing capabilities. Examples of the processor 22 include, but are not limited to, a central processing unit, a graphics processing unit, a digital signal processor, various specialized artificial intelligence computing chips, various processors for running machine learning model algorithms, and may also be any appropriate controller, microcontroller, processor, etc. The processor 22 executes the various methods and processes of this embodiment, such as, for example, a resource reading method according to an embodiment of the present application.

[0084] Optionally, the bus 25 may include a path for transmitting information. According to different functions, the bus 25 may be divided into an address bus, a data bus, a control bus, etc.

[0085] In an optional implementation, an embodiment of the present application further provides a computer storage medium having a computer program stored thereon, which, when executed by a computer, enables the computer to perform the method of the above-described method embodiment. Part or all of the computer program can be loaded and / or installed into the memory 21 of the electronic device 20. When the computer program is executed by the processor 22, one or more steps of a resource reading method of the embodiment of the present application can be performed.

[0086] Optionally, the computer-readable storage medium may be a random access memory, a read-only memory, a programmable read-only memory, an erasable programmable read-only memory, an electrically erasable programmable read-only memory, or the like.

[0087] Obviously, the above embodiments of the present application are merely examples for clearly illustrating the technical solution of the present application, and are not intended to limit the specific implementation methods of the present application. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the claims of the present application shall be included in the scope of protection of the claims of the present application.

Claims

1. A resource reading method, characterized in that: The method comprises: According to the preset compressed file field, the target file path is converted to obtain a compressed file path; the target file path is generated according to the target resource to be read; the compressed file path represents the file path of the compressed file package containing the target resource; According to the compressed file path, the corresponding resource file is read in the memory cache as the target resource; the resource file is decompressed from the compressed file package corresponding to the compressed file path to the memory cache.

2. The resource reading method according to claim 1, characterized in that: The step of performing path conversion on the target file path according to the preset compressed file field to obtain the compressed file path includes: According to the preset compressed file field, query in the target file path to obtain the corresponding path file field; According to the preset compressed file type, the corresponding compressed file suffix is added after the path file field to obtain a replacement file field; The path file field in the target file path is replaced by the replacement file field to obtain the compressed file path.

3. The resource reading method according to claim 1, characterized in that: The step of reading the corresponding resource file in the memory cache as the target resource according to the compressed file path includes: A memory mapping table is queried according to the compressed file path to obtain a query result, and a corresponding resource file is read from the memory cache as a target resource according to the query result; wherein the memory mapping table records the mapping relationship between the resource file in the memory cache and the compressed file path.

4. The resource reading method according to claim 3, characterized in that: The querying of the memory mapping table according to the compressed file path to obtain a query result, and reading a corresponding resource file from the memory cache as a target resource according to the query result, includes: The memory mapping table is queried according to the compressed file path. If the corresponding resource file exists in the memory cache, it is read as the target resource; otherwise, the corresponding compressed file package is obtained from the local storage space, its resource file is decompressed into the memory cache, and then read as the target resource, and the memory mapping table is updated.

5. The resource reading method according to claim 3, characterized in that: The querying of the memory mapping table according to the compressed file path to obtain a query result, and reading a corresponding resource file from the memory cache as a target resource according to the query result, includes: According to the compressed file path, the corresponding compressed file package is queried in the local storage space. If the corresponding compressed file package exists in the local storage space, the memory mapping table is queried according to the compressed file path to obtain the query result, and the corresponding resource file is read from the memory cache as the target resource according to the query result.

6. The resource reading method according to any one of claims 4 or 5, characterized in that: The obtaining of the corresponding compressed file package according to the compressed file path includes: According to a preset network resource mapping table, the network resource address of the corresponding compressed file package is obtained through the compressed file path; the network resource mapping table records the mapping relationship between the compressed file package and the network resource address; Download the corresponding compressed file package to the local storage space according to the network resource address.

7. The resource reading method according to any one of claims 1 to 5, characterized in that: The resource files stored in the memory cache are periodically cleared according to a preset clearing strategy.

8. A resource reading device, characterized in that: The device comprises: A path replacement module is used to perform path conversion on the target file path according to a preset compressed file field to obtain a compressed file path; the target file path is generated according to the target resource to be read; the compressed file path represents the file path of the compressed file package containing the target resource; The resource reading module is used to read the corresponding resource file in the memory cache as the target resource according to the compressed file path; the resource file is decompressed from the compressed file package corresponding to the compressed file path to the memory cache.

9. An electronic device, characterized in that: include: a memory for storing one or more computer programs; The processor implements the resource reading method according to any one of claims 1 to 7 when the one or more computer programs are executed by the processor.

10. A computer-readable storage medium storing computer instructions, wherein the computer instructions are configured to enable a processor to implement the resource reading method according to any one of claims 1 to 7 when executed.

Citation Information

Patent Citations

  • URL rewriting method and equipment

    CN101477540A

  • Processing method and device of dynamic library file

    CN106406923A

  • Data processing method and device, electronic equipment and computer readable storage medium

    CN111008178A

  • Offline resource file generation method and device, equipment and storage medium

    CN112632425A

  • Resource data reading method and device and storage medium

    CN113377722A