Search

CN-121996637-A - Resource file access method, device and storage medium

CN121996637ACN 121996637 ACN121996637 ACN 121996637ACN-121996637-A

Abstract

The invention provides a resource file access method, a device and a storage medium, wherein the resource file access method receives a resource file acquisition request, generates a Redis cache record for a Group address unique identifier generated after a FastDFS distributed file system is uploaded to a resource file, stores hot spot resource files in the FastDFS distributed file system, periodically scans and transfers unusual data to a NAS network attached storage system, and empties the Redis cache record of the corresponding resource file after the transfer is completed. The invention takes account of the advantages of two storage parallelism of FastDFS distributed file systems and NAS network attached storage systems, hot data can be obtained through FastDFS distributed file systems and cold data can be obtained through NAS network attached storage systems when file previewing is carried out, and file storage performance and service response are improved.

Inventors

  • FAN QIANG
  • Yuan Chaogui
  • ZHANG YAN

Assignees

  • 昆仑数智科技有限责任公司
  • 中国石油天然气集团有限公司

Dates

Publication Date
20260508
Application Date
20241107

Claims (12)

  1. 1. A method for accessing a resource file, comprising the steps of: Receiving an uploaded resource file, judging the service type of the resource file, and generating a first part of a preview address of the resource file by utilizing the service type identification of the resource file; Uploading the original resource file to FastDFS distributed file system, using the Group address unique identification of the resource file returned by FastDFS distributed file system as the second part of the preview address, and generating the preview address of the resource file by combining the first part; writing the metadata of the resource file into a database table, writing the unique Group address identification of the resource file into a cache library, and returning the information of the resource file; And periodically screening the resource file metadata with the time length longer than a preset period in a database table, transmitting resource file originals corresponding to the screened resource file metadata to a NAS network attached storage system for storage by a FastDFS distributed file system, and deleting a Group address unique identifier corresponding to the screened resource file metadata in the cache library.
  2. 2. The resource file access method of claim 1, further comprising the steps of: Receiving a resource acquisition request sent by a client, wherein the resource acquisition request at least comprises a preview address of a target resource file; Obtaining a Group address unique identifier of the resource file according to the preview address of the target resource file; Judging whether the cache library contains the unique Group address identifier, if so, acquiring the target resource file from the FastDFS distributed file system, otherwise, acquiring the target resource file from the NAS network attached storage system.
  3. 3. The method for accessing resource files according to claim 1 or 2, wherein after the metadata of the resource file is written into the database table and the unique Group address identifier of the resource file is written into the cache library, it is sequentially determined FastDFS whether the metadata of the resource file is written into the database successfully, whether the unique Group address identifier of the resource file is written into the database successfully, and the resource file information is returned after the metadata of the resource file is written into the database successfully.
  4. 4. The resource file accessing method according to claim 1 or 2, wherein periodically filtering resource file metadata stored in the database table for a period longer than a preset period, and transmitting the resource file original corresponding to the filtered resource file metadata from the FastDFS distributed file system to the NAS network attached storage system for storage, includes: Screening out resource file metadata which is larger than a preset period in a database table through a timing task, and setting a field archiving identification stored in the database table as to-be-archived; And transmitting the resource file corresponding to the screened resource file metadata to a NAS network attached storage system by using a FastDFS distributed file system through an Http protocol, and setting a field archiving identification stored in a database table as archived.
  5. 5. The resource file access method as claimed in claim 2, wherein after receiving the resource acquisition request from the client, it is first determined whether the target resource file corresponding to the target resource preview address has been cached in the client; If the target resource file is cached in the client and is not expired, returning a response of continuing to use the cache to the client, and acquiring the target resource file in the local cache by the client, wherein the subsequent steps are not executed.
  6. 6. The resource file access method of claim 5 wherein returning a response to continue using the cache to the client further comprises returning expiration time of the cache and cache verification information.
  7. 7. The resource file access method as claimed in claim 2, wherein the resource acquisition request further includes a request source address, and before the determining determines whether the target resource file corresponding to the target resource preview address has been cached in the client, it is further checked whether the request source address satisfies the anti-hotlink filter address, and if not, it is returned directly to prohibit access.
  8. 8. The method of claim 2, wherein determining whether the Group address unique identifier is included in the repository, and if so, obtaining the target resource file from the FastDFS distributed file system, and otherwise, obtaining the target file from the NAS network attached storage system comprises: Judging whether the cache library contains the unique Group address identifier, if so, searching the resource file in FastDFS distributed file system by using the unique Group address identifier, otherwise, Inquiring whether resource file metadata corresponding to the Group address unique identifier exists in a database table, and if so, acquiring a target resource file from an NAS network attached storage system through an Http request according to the resource file metadata.
  9. 9. A resource file management system, comprising at least a file management micro-service, a timing micro-service, an archiving micro-service, fastDFS distributed file system, NAS network attached storage system, a database, a cache, wherein: The FastDFS distributed file system is used for storing original files of resource files, the database is used for storing metadata of the resource files, and the cache library is used for storing unique Group address identifiers of the resource files; The timing micro-service is used for generating a timing expiration notice for the file management micro-service; The file management micro service is used for receiving the uploaded resource file, judging the service type of the resource file, generating a first part of a preview address of the resource file by utilizing the service type identification of the resource file, uploading a resource file original to a FastDFS distributed file system, taking a Group address unique identification of the resource file returned by the FastDFS distributed file system as a second part of the preview address, combining the first part to generate the preview address of the resource file, writing resource file metadata into a database table, writing the Group address unique identification of the resource file into a cache library, returning file information, screening the resource file metadata which is longer than a preset period when the storage time in the database table is longer than the preset period after receiving a timing expiration notification generated by the timing micro service, transmitting the resource file original corresponding to the screened resource file metadata to an NAS network attached storage system by the FastDFS distributed file system, and deleting the Group address unique identification corresponding to the screened resource file metadata in the cache library.
  10. 10. The resource file management system of claim 9 wherein the file management microservice is further configured to obtain a Group address unique identifier of the resource file according to a preview address of the target resource file after receiving the resource acquisition request from the client, determine whether the Group address unique identifier is included in the repository, and if so, obtain the target resource file from the FastDFS distributed file system, otherwise, obtain the target resource file from the NAS network attached storage system.
  11. 11. A computer device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, characterized in that the processor implements the method of any of claims 1 to 8 when executing the computer program.
  12. 12. A computer readable storage medium, characterized in that the computer readable storage medium stores a computer program for executing the method of any one of claims 1 to 8.

Description

Resource file access method, device and storage medium Technical Field The present invention relates to the field of computer technologies, and in particular, to a method and an apparatus for accessing a resource file, and a storage medium. Background Currently, an application program integrates more and more functions, and opening each functional page of the application can call a large amount of requests for loading resource files, so that a large amount of network bandwidth is consumed for loading the resource files. Also, the general resource files may be stored in FastDFS distributed file systems or NAS network attached storage systems, where Input/output (I/O) of the NAS network attached storage system has access pressure during peak hours. Disclosure of Invention The inventor finds that the current acquisition of the resource file consumes a large amount of network bandwidth in practical application, and the service performance and response efficiency are improved, and creatively self-discovers a resource file access method through a large amount of researches. Specific: In a first aspect, the present invention discloses a resource file access method, which includes the following steps: Receiving an uploaded resource file, judging the service type of the resource file, and generating a first part of a preview address of the resource file by utilizing the service type identification of the resource file; Uploading the original resource file to FastDFS distributed file system, using the Group address unique identification of the resource file returned by FastDFS distributed file system as the second part of the preview address, and generating the preview address of the resource file by combining the first part; writing the metadata of the resource file into a database table, writing the unique Group address identification of the resource file into a cache library, and returning the information of the resource file; And periodically screening the resource file metadata with the time length longer than a preset period in a database table, transmitting resource file originals corresponding to the screened resource file metadata to a NAS network attached storage system for storage by a FastDFS distributed file system, and deleting a Group address unique identifier corresponding to the screened resource file metadata in the cache library. Further, receiving a resource acquisition request sent by a client, wherein the resource acquisition request at least comprises a target resource preview address; obtaining a Group address unique identifier of the resource file according to the target resource preview address; judging whether the cache library contains the unique Group address identifier, if so, acquiring the target resource file from the FastDFS distributed file system, otherwise, acquiring the target file from the NAS network attached storage system. Further, after the metadata of the resource file is written into the database table and the unique Group address identifier of the resource file is written into the cache, whether the metadata of the resource file is written into the database is successfully or not needs to be sequentially judged FastDFS, whether the metadata of the resource file is written into the database is successfully or not, whether the unique Group address identifier of the resource file is written into the database is successfully or not, and the resource file information is returned after the unique Group address identifier of the resource file is successfully written into the database. Further, periodically filtering resource file metadata stored in a database table with a time period longer than a preset period, and transmitting a resource file original corresponding to the filtered resource file metadata to a NAS network attached storage system for storage by a FastDFS distributed file system, including: Screening out resource file metadata which is larger than a preset period in a database table through a timing task, and setting a field archiving identification stored in the database table as to-be-archived; And transmitting the resource file corresponding to the screened resource file metadata to a NAS network attached storage system by using a FastDFS distributed file system through an Http protocol, and setting a field archiving identification stored in a database table as archived. Further, after receiving a resource acquisition request sent by a client, judging whether a target resource file corresponding to a target resource preview address is cached in the client; If the target resource file is cached in the client and is not expired, returning a response of continuing to use the cache to the client, and acquiring the target resource file in the local cache by the client, wherein the subsequent steps are not executed. Further, the returning of the response of continuing to use the cache to the client also comprises returning the expiration time of the cache and the cach