Dynamic caching method, device and equipment of file and storage medium

By transferring files from the local cache module to the storage server and unlocking them when multiple clients access the system, the problem of data caching by multiple clients in existing technologies is solved, achieving wider applicability and higher storage speed.

CN116821072BActive Publication Date: 2026-03-17CHINA UNITED NETWORK COMM GRP CO LTD +2
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-06-29
Publication Date
2026-03-17

AI Technical Summary

Technical Problem

Existing caching methods are only suitable for situations where a single client accesses data, and cannot be applied to multiple clients, resulting in a limited scope of application and poor applicability.

Method used

When multiple clients access a target file, the target file is transferred from the local cache module of the client with the locking relationship to the server's storage server, and the locking relationship is released, allowing the first client to access the file through the storage server; after the access is completed, the file is transferred back to the client's local cache module, thus realizing dynamic caching.

Benefits of technology

This improves the applicability and scope of caching methods, allowing multiple clients to effectively cache data, thereby enhancing the storage speed and computational efficiency of distributed storage systems.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116821072B_ABST
    Figure CN116821072B_ABST
Patent Text Reader

Abstract

The application provides a dynamic caching method, device and equipment of a file and a storage medium. The method comprises the following steps: in response to receiving an access request of any first client accessing a target file, adding the first client to an access list; if the number of the first clients accessing the target file is multiple, determining a second client from the multiple first clients, wherein the second client is a client having a locking relationship with the target file, and the target file is stored in a local caching module of the second client; transferring the target file from the local caching module of the second client to a storage server of a server, and releasing the locking relationship between the second client and the target file, so that the first client accesses the target file through the storage server; if the first client finishes accessing the target file, transferring the target file from the storage server to the local caching module of the second client again, and re-establishing the locking relationship between the second client and the target file.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of cloud computing technology, and in particular to a method, apparatus, device and storage medium for dynamic caching of files. Background Technology

[0002] With the development of artificial intelligence and cloud computing technologies, there are increasing demands on the storage speed of distributed storage systems to meet data request efficiency requirements. Therefore, improving storage speed to enhance the operational efficiency of distributed storage systems has become a pressing issue.

[0003] In existing technologies, persistent client-side caching technology is used to persistently cache data on the client side. When the client sends a data request, it can directly retrieve the data from the client's local storage instead of retrieving the data from the server over the network. This saves network latency for data transmission and thus improves data storage speed.

[0004] However, when other clients also need to access the same data, to avoid access conflicts and maintain data consistency, the data persistently cached by the client will be invalidated, causing the client to be unable to retrieve the data locally. Therefore, existing caching methods are only suitable for situations where a single client accesses data, and not for situations where multiple clients access it, thus having a limited scope and poor applicability. Summary of the Invention

[0005] This application provides a method, apparatus, device, and storage medium for dynamic caching of files, which can improve the applicability and scope of the caching method.

[0006] In a first aspect, this application provides a dynamic caching method for files, applied to a server in a distributed storage system, the distributed storage system including multiple clients and servers; the method includes:

[0007] In response to receiving any access request from a first client to access a target file, the first client is added to the access list, wherein the access list includes at least one first client accessing the target file;

[0008] If there are multiple first clients accessing the target file, then a second client is determined from the multiple first clients, wherein the second client is a client that has a locking relationship with the target file, and the target file is stored in the local cache module of the second client;

[0009] The target file is transferred from the local storage module of the second client to the storage server of the server, and the locking relationship between the second client and the target file is released, so that the first client can access the target file through the storage server;

[0010] If the first client finishes accessing the target file, the target file is transferred from the storage server back to the local cache module of the second client, and the locking relationship between the second client and the target file is re-established.

[0011] In one possible design, the method further includes: if the number of first clients accessing the target file is one, then the target file is transferred from the storage server to the local cache module of the first client, and a locking relationship is established between the first client and the target file.

[0012] In one possible design, the access request includes cache status information of the first client; correspondingly, before transferring the target file from the storage server to the local cache module of the first client, the method further includes: obtaining cache status information of the first client; if the cache status information is cacheable, then the step of transferring the target file from the storage server to the local cache module of the first client is executed; if the cache status information is uncacheable, then the step of transferring the target file from the storage server to the local cache module of the first client is not executed.

[0013] In one possible design, the local caching module includes a caching unit and a file-downloading unit, wherein the caching unit includes multiple files and lock information corresponding to each file; correspondingly, the step of transferring the target file from the local storage module of the second client to the storage server of the server and releasing the lock relationship between the second client and the target file includes: extracting the target file and the file lock information corresponding to the target file from the multiple files included in the caching unit according to the file identifier of the target file; transferring the target file to the storage server of the server through the file-downloading unit, and setting the file lock information corresponding to the target file to an unlocked state.

[0014] In one possible design, the local cache module further includes a recycling unit; correspondingly, the method further includes: obtaining the capacity of cached files in the cache unit and the total capacity of the cache unit; if the ratio of the capacity of the cached files to the total capacity is greater than a preset ratio, then querying the cached files for target files that have not been accessed within a preset time period; and deleting the target files through the recycling unit.

[0015] In one possible design, the target file includes multiple unsynchronized data; correspondingly, the step of transferring the target file to the server's storage server via the down-flush unit includes: dividing the multiple unsynchronized data into multiple data groups of preset capacity; and sequentially transferring each of the preset capacity data groups to the server's storage server.

[0016] In one possible design, the method further includes: in response to receiving a write instruction for the target file, determining whether the target file contains unsynchronized data; if the target file contains unsynchronized data, determining whether the plurality of new data to be written included in the write instruction has the same data as the unsynchronized data; if the plurality of new data to be written has the same data as the unsynchronized data, then synchronizing the unsynchronized data to the storage server before executing the write instruction.

[0017] Secondly, this application provides a dynamic file caching device applied to a server in a distributed storage system, the distributed storage system including multiple clients and servers; the device includes:

[0018] A receiving module is configured to add the target file to an access list in response to receiving an access request from any first client to access the target file, wherein the access list includes at least one first client accessing the target file;

[0019] The determining module is configured to determine a second client from the multiple first clients if there are multiple first clients accessing the target file, wherein the second client is a client that has a locking relationship with the target file, and the target file is stored in the local cache module of the second client;

[0020] The transfer module is used to transfer the target file from the local storage module of the second client to the storage server of the server, and release the locking relationship between the second client and the target file, so that the first client can access the target file through the storage server;

[0021] The locking module is used to, if the first client finishes accessing the target file, transfer the target file from the storage server back to the local cache module of the second client, and re-establish the locking relationship between the second client and the target file.

[0022] Thirdly, this application provides an electronic device, including: a processor and a memory;

[0023] The memory stores computer-executed instructions;

[0024] The processor executes computer execution instructions stored in the memory, causing the processor to perform the dynamic caching method for files as described in the first aspect and various possible designs of the first aspect.

[0025] Fourthly, this application provides a computer storage medium storing computer execution instructions, which, when executed by a processor, implement the dynamic caching method for files as described in the first aspect and various possible designs of the first aspect.

[0026] Fifthly, this application provides a computer program product, including a computer program that, when executed by a processor, implements the dynamic caching method for files described in the first aspect and various possible designs of the first aspect.

[0027] The dynamic caching method, apparatus, device, and storage medium provided in this application, in response to receiving an access request from any first client to access a target file, adds the first client to the access list; if there are multiple first clients accessing the target file, a second client is determined from among the multiple first clients, wherein the second client is a client with a locked relationship with the target file, and the target file is stored in the second client's local cache module; the target file is transferred from the second client's local storage module to the server's storage server, and the locked relationship between the second client and the target file is released, allowing the first client to access the target file through the storage server; if the first client finishes accessing the target file, the target file is transferred back from the storage server to the second client's local cache module, and the locked relationship between the second client and the target file is re-established. Because the file can be transferred from the second client's local cache module to the storage server when the first client accesses the file, and can be automatically transferred back from the storage server to the previously locked local cache module of the second client after the first client finishes accessing the file, dynamic caching of files is achieved, facilitating direct access to the target file by the second client. Therefore, this application can solve the problem of data not being cached when multiple clients access the same data, thus improving the applicability and scope of this caching method. Attached Figure Description

[0028] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0029] Figure 1This is a schematic diagram illustrating an application scenario of the dynamic caching method for files provided in this application embodiment;

[0030] Figure 2 A flowchart illustrating the dynamic caching method for files provided in this application embodiment. Figure 1 ;

[0031] Figure 3 A flowchart illustrating the dynamic caching method for files provided in this application embodiment. Figure 2 ;

[0032] Figure 4 A schematic diagram of the structure of the dynamic caching device for files provided in the embodiments of this application;

[0033] Figure 5 This is a schematic diagram of the hardware structure of the electronic device provided in the embodiments of this application. Detailed Implementation

[0034] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0035] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties. Furthermore, the collection, use and processing of the relevant data must comply with relevant laws, regulations and standards, and corresponding operation entry points are provided for users to choose to authorize or refuse.

[0036] With the development of artificial intelligence and cloud computing technologies, there are increasing demands on the storage speed of distributed storage systems to meet data request efficiency requirements. Therefore, improving storage speed to enhance the operational efficiency of distributed storage systems has become a pressing issue.

[0037] In existing technologies, persistent client-side caching is used to cache data on the client side. When a client sends a data request, it can retrieve the data directly from its local machine instead of fetching it from the server over the network. This saves network latency and improves data storage speed. However, when other clients also need to access the same data, to avoid access conflicts and maintain data consistency, the cached data on the client side will become invalid, preventing the client from retrieving the data locally. Therefore, existing caching methods are only suitable for single-client access to data, and not for multiple-client access, thus having a limited scope and poor applicability.

[0038] Therefore, improving storage speed under multiple client access scenarios is a pressing technical problem that needs to be solved.

[0039] To address the aforementioned technical problems, this application proposes the following technical concept: Upon receiving an access request from any first client to access a target file, the target file is transferred from the second client's local storage module to the server's storage server, and the locking relationship between the second client and the target file is released, allowing the first client to access the target file through the storage server. If the first client finishes accessing the target file, the target file is transferred back from the storage server to the second client's local cache module, and the locking relationship between the second client and the target file is re-established. Since the file can be transferred from the second client's local cache module to the storage server when the first client accesses the file, and automatically transferred back to the previously locked second client's local cache module after the first client's access ends, dynamic file caching is achieved, facilitating direct access to the target file by the second client. Therefore, this application can solve the problem of multiple clients accessing the same data without data caching, thus improving the scope and applicability of the caching method.

[0040] Figure 1 This is a schematic diagram illustrating an application scenario of the dynamic file caching method provided in this application embodiment. For example... Figure 1As shown, this dynamic caching method is applied to a server in a distributed storage system, which includes multiple clients 101 and a server 102. Client 102 includes a master server and a storage server. The master server communicates with each client 101 via wired or wireless means to receive and send data, and the storage server stores the data. For example, when a first client needs to access data, it sends an access request to the master server. The master server retrieves the data from the storage server and sends it to the first client. After caching the data, the first client can lock the data. Furthermore, when other clients need to access the locked data, the first client can unlock the data and transfer it to the storage server, allowing other clients to access the data from the storage server. The dynamic caching method for files proposed in this application will be described in detail below through detailed embodiments.

[0041] Figure 2 A flowchart illustrating the dynamic caching method for files provided in this application embodiment. Figure 1 In this embodiment, the executing entity can be a terminal or a server; no special restrictions are imposed here.

[0042] like Figure 2 As shown, the method includes:

[0043] S201. In response to receiving an access request from any first client to access a target file, add the first client to the access list, wherein the access list includes at least one first client accessing the target file.

[0044] In this step, if there is only one first client accessing the target file, that first client is the client accessing the file in this instance. If there are multiple first clients accessing the target file, these multiple first clients include both the client accessing the file in this instance and clients accessing the file in previous instances.

[0045] For example, the first client accessing the target file this time is client 0, and the client accessing it previously is client 1. In this case, the access list includes two clients that were the first to access the target file.

[0046] S202. If there are multiple first clients accessing the target file, then a second client is determined from among the multiple first clients, wherein the second client is a client that has a locking relationship with the target file, and the target file is stored in the local cache module of the second client.

[0047] Optionally, the server includes a metadata service center, which records the storage location of each file. Accordingly, determining the second client from multiple first clients includes: determining the storage location of the target file using its file identifier; and selecting the client whose storage location is located from the multiple first clients as the second client.

[0048] For example, the number of clients accessing the target file is two: client 0 and client 1. The file identifier of the target file is: image A; the storage location of image A is determined to be: the local storage module of client 1; client 1 is determined to be the second client.

[0049] It's important to note that the file is stored in the local storage module, meaning it's cached on the client's local machine. In this case, a locking relationship exists between the client and the file, allowing the client to access the file directly from its local machine. This reduces network latency during data transmission and improves data storage speed.

[0050] In this application, the local cache module can be a DPCC (Distributed Persistent ClientCache) module.

[0051] S203. Transfer the target file from the local storage module of the second client to the storage server of the server, and release the lock relationship between the second client and the target file so that the first client can access the target file through the storage server.

[0052] Optionally, the local caching module includes a caching unit and a download unit, wherein the caching unit includes multiple files and lock information corresponding to each file; accordingly, the target file is transferred from the local storage module of the second client to the storage server of the server, and the locking relationship between the second client and the target file is released, including: extracting the target file and the file lock information corresponding to the target file from the multiple files included in the caching unit according to the file identifier of the target file; and transferring the target file to the storage server of the server through the download unit, and setting the file lock information corresponding to the target file to the unlocked state.

[0053] For example, the local caching module is a DPCC module. The DPCC module includes a cache unit and a flush unit; wherein, the cache unit can be represented by Cache, and the flush unit can be represented by Fluster.

[0054] In some embodiments, the target file includes multiple unsynchronized data (i.e., dirty data); accordingly, the target file is transferred to the server's storage server via the flushing unit, including: dividing the multiple unsynchronized data into multiple data groups of preset capacity; and sequentially transferring each preset capacity data group to the server's storage server. This application embodiment does not specifically limit the value of the preset capacity, which can be set and modified as needed. For example, the preset capacity can be 1M, 10M, 20M, etc.

[0055] Because transmitting small amounts of unsynchronized data incurs numerous transmission requests, resulting in low transmission efficiency, this method divides the unsynchronized data into multiple pre-defined data groups. These groups are then transferred to the storage server, reducing the number of transmission requests and network interactions, thus improving transmission efficiency.

[0056] It should be noted that, in this embodiment of the application, data that has not been accessed for a long time in the local cache module can also be scanned periodically and deleted if the data has not been accessed for a certain period of time, so as to release the cache space of the local cache module.

[0057] Optionally, the local cache module further includes a recycling unit; correspondingly, the step of deleting data that has not been accessed for a long time is as follows: querying the cached files for target files that have not been accessed within a preset time period; and deleting the target files through the recycling unit. This application embodiment does not specifically limit the value of the preset time period, which can be set and modified as needed. For example, the preset time period can be 1 week, 2 weeks, 1 month, etc. For example, the recycling unit can be represented by a Reaper; that is, the DPCC module includes a Cache unit, a Fluster unit, and a Reaper unit.

[0058] Here, by periodically scanning the local cache module for data that has not been accessed for a long time and deleting data that has not been accessed for a certain period of time, the cache space of the local cache module is freed up, thereby improving the read and write speed of the local cache module.

[0059] In another embodiment, data is deleted only when the cache space of the local cache module is low. Accordingly, the steps for deleting data that has not been accessed for a long time are as follows: obtain the capacity of the cached files in the cache unit and the total capacity of the cache unit; if the ratio of the capacity of the cached files to the total capacity is greater than a preset ratio, then query the cached files for target files that have not been accessed within a preset time period; and delete the target files through the recycling unit.

[0060] This application does not impose a specific limitation on the value of the preset ratio, which can be set and modified as needed. For example, the preset ratio can be 0.7, 0.8, 0.9, etc.

[0061] Here, when the local cache module has little remaining cache space, it periodically scans data that has not been accessed for a long time and deletes data that has not been accessed for a certain period of time in order to free up cache space in the local cache module. This ensures the read and write speed of the local cache module while also providing stability for the data stored in the local cache module.

[0062] S204. If the first client finishes accessing the target file, the target file is transferred from the storage server to the local cache module of the second client, and the locking relationship between the second client and the target file is re-established.

[0063] In some embodiments, if the first client finishes accessing the target file, the target file is directly transferred from the storage server to the local cache module of the second client, and the locking relationship between the second client and the target file is re-established.

[0064] In other embodiments, if the first client finishes accessing the target file, the target file will be transferred from the storage server to the second client's local cache module only when the second client accesses the target file again, and the locking relationship between the second client and the target file will be re-established.

[0065] The dynamic caching method for files provided in this application can transfer the file from the local cache module of the second client to the storage server when the first client accesses the file; after the first client finishes accessing the file, it can automatically transfer the file back from the storage server to the previously locked local cache module of the second client, thus achieving dynamic caching of files and facilitating direct access to the target file by the second client. Therefore, this application can solve the problem of data not being cached when multiple clients access the same data, thereby improving the applicability and scope of this caching method.

[0066] Figure 3 A flowchart illustrating the dynamic caching method for files provided in this application embodiment. Figure 2 In the embodiments of this application, in Figure 2 Based on the provided embodiments, a detailed description of the dynamic caching method when the number of first clients is one is given. For example... Figure 3 As shown, the method also includes:

[0067] S205. If the number of first clients accessing the target file is one, then the target file is transferred from the storage server to the local cache module of the first client, and a locking relationship is established between the first client and the target file.

[0068] In this embodiment of the application, when there is only one first client accessing the target file, there is no access contention. In this case, the target file can be cached by the first client.

[0069] It should be noted that before caching the target file to the first client, the cache status information of the first client needs to be confirmed. The target file will only be cached on the first client if it is in a cacheable state. If the first client is in a non-cacheable state, the target file will not be cached, and will instead be accessed from the storage server.

[0070] Optionally, the access request includes the cache status information of the first client; correspondingly, before transferring the target file from the storage server to the local cache module of the first client, the method further includes: obtaining the cache status information of the first client; if the cache status information is cacheable, then the step of transferring the target file from the storage server to the local cache module of the first client is executed; if the cache status information is non-cacheable, then the step of transferring the target file from the storage server to the local cache module of the first client is not executed.

[0071] The cache status information can be determined using the tagging information of the local cache module. If the access request includes the tagging information of the local cache module, the cache status is determined to be cacheable; if the access request does not include the tagging information of the local cache module, the cache status is determined to be non-cacheable. The tagging information of the local cache module can be a DPCC tag.

[0072] In some embodiments, users can set the cache status information of the client. When the client needs to cache data, the cache status information is set to a cacheable state, and when the client does not need to cache data, the cache status information is set to a non-cacheable state.

[0073] It should be noted that the caching method in this application can also update the data in the target file. If the target file is in the process of being transferred, it contains unsynchronized data. In this case, it is necessary to wait until the transfer of the target file is completed before updating the data in the target file.

[0074] Accordingly, the steps for updating the data are as follows: in response to receiving a write instruction for the target file, determine whether the target file contains unsynchronized data; if the target file contains unsynchronized data, determine whether the multiple new data to be written included in the write instruction have the same data as the unsynchronized data; if the multiple new data to be written have the same data as the unsynchronized data, synchronize the unsynchronized data to the storage server before executing the write instruction.

[0075] In this application example, when the target file contains unsynchronized data, the data in the target file is updated only after the target file transfer is completed, thereby ensuring the consistency of the file data and improving the validity and stability of the file.

[0076] Figure 4 This is a schematic diagram of the structure of a dynamic caching device for files provided in an embodiment of this application. The dynamic caching device is applied to a server in a distributed storage system, which includes multiple clients and servers; for example... Figure 4 As shown, the device includes: a receiving module 401, a determining module 402, a transfer module 403, and a locking module 404;

[0077] The receiving module 401 is configured to add the target file to the access list in response to receiving an access request from any first client to access the target file, wherein the access list includes at least one first client accessing the target file;

[0078] The determination module 402 is used to determine the second client from the multiple first clients if there are multiple first clients accessing the target file, wherein the second client is a client that has a locking relationship with the target file, and the target file is stored in the local cache module of the second client;

[0079] The transfer module 403 is used to transfer the target file from the local storage module of the second client to the storage server of the server, and release the locking relationship between the second client and the target file so that the first client can access the target file through the storage server;

[0080] Locking module 404 is used to transfer the target file from the storage server to the local cache module of the second client and re-establish the locking relationship between the second client and the target file if the first client finishes accessing the target file.

[0081] In one possible design, the transfer module 403 is also used to transfer the target file from the storage server to the local cache module of the first client if the number of first clients accessing the target file is one, and to establish a locking relationship between the first client and the target file.

[0082] In one possible design, the access request includes cache status information of the first client; correspondingly, the transfer module 403 is also used to obtain the cache status information of the first client; if the cache status information is cacheable, the step of transferring the target file from the storage server to the local cache module of the first client is executed; if the cache status information is non-cacheable, the step of transferring the target file from the storage server to the local cache module of the first client is not executed.

[0083] In one possible design, the local caching module includes a caching unit and a flushing unit, wherein the caching unit includes multiple files and lock information corresponding to each file; correspondingly, the transfer module 403 transfers the target file from the local storage module of the second client to the storage server of the server, and releases the locking relationship between the second client and the target file, specifically including: extracting the target file and the file lock information corresponding to the target file from the multiple files included in the caching unit according to the file identifier of the target file; transferring the target file to the storage server of the server through the flushing unit, and setting the file lock information corresponding to the target file to the unlocked state.

[0084] In one possible design, the local cache module also includes a recycling unit; correspondingly, the method also includes: a deletion module; the deletion module is used to obtain the capacity of the cached files in the cache unit and the total capacity of the cache unit; if the ratio of the capacity of the cached files to the total capacity is greater than a preset ratio, then query the cached files for target files that have not been accessed within a preset time period; and delete the target files through the recycling unit.

[0085] In one possible design, the target file contains multiple unsynchronized data; accordingly, the transfer module 403 transfers the target file to the server's storage server through the down-flush unit, including: dividing the multiple unsynchronized data into multiple data groups of preset capacity; and sequentially transferring each preset capacity data group to the server's storage server.

[0086] In one possible design, the system further includes: a data writing module; the data writing module is used to, in response to receiving a write instruction for a target file, determine whether the target file contains unsynchronized data; if the target file contains unsynchronized data, determine whether the multiple new data to be written included in the write instruction have the same data as the unsynchronized data; if the multiple new data to be written have the same data as the unsynchronized data, then synchronize the unsynchronized data to the storage server before executing the write instruction.

[0087] The apparatus provided in this embodiment can be used to execute the technical solutions of the above method embodiments. Its implementation principle and technical effects are similar, and will not be described again here.

[0088] Figure 5 This is a schematic diagram of the hardware structure of the electronic device provided in an embodiment of this application. Figure 5 As shown, the electronic device of this embodiment includes: a processor 501 and a memory 502; wherein

[0089] Memory 502 is used to store instructions executed by the computer;

[0090] The processor 501 is used to execute computer execution instructions stored in the memory to implement the various steps performed by the electronic device in the above embodiments. For details, please refer to the relevant descriptions in the foregoing method embodiments.

[0091] Alternatively, the memory 502 can be either standalone or integrated with the processor 501.

[0092] When the memory 502 is set up independently, the electronic device also includes a bus 503 for connecting the memory 502 and the processor 501.

[0093] This application also provides a computer storage medium storing computer execution instructions, which, when executed by a processor, implements the dynamic caching method for files described in the above-described method embodiments.

[0094] This application also provides a computer program product, including a computer program that, when executed by a processor, implements the dynamic caching method for files described in the above method embodiments.

[0095] In the several embodiments provided in this application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are merely illustrative; for instance, the division of modules is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple modules may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be indirect coupling or communication connection through some interfaces, devices, or modules, and may be electrical, mechanical, or other forms.

[0096] The modules described as separate components may or may not be physically separate. The components shown as modules may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to implement the solution of this embodiment according to actual needs.

[0097] Furthermore, the functional modules in the various embodiments of this application can be integrated into one processing unit, or each module can exist physically separately, or two or more modules can be integrated into one unit. The unit composed of the above modules can be implemented in hardware or in the form of hardware plus software functional units.

[0098] The integrated modules described above, implemented as software functional modules, can be stored in a computer-readable storage medium. These software functional modules, stored in a storage medium, include several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) or processor to execute partial steps of the methods in the various embodiments of this application.

[0099] It should be understood that the aforementioned processor can be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), etc. A general-purpose processor can be a microprocessor or any conventional processor. The steps of the method disclosed in this invention can be directly manifested as being executed by a hardware processor, or executed by a combination of hardware and software modules within the processor.

[0100] The memory may include high-speed RAM, and may also include non-volatile storage (NVM), such as at least one disk storage device, and may also be a USB flash drive, external hard drive, read-only memory, disk or optical disc, etc.

[0101] The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. Buses can be categorized as address buses, data buses, control buses, etc. For ease of illustration, the buses shown in the accompanying drawings are not limited to a single bus or a single type of bus.

[0102] The aforementioned storage medium can be implemented from any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk. The storage medium can be any available medium accessible to general-purpose or special-purpose computers.

[0103] An exemplary storage medium is coupled to a processor, enabling the processor to read information from and write information to the storage medium. Alternatively, the storage medium can be an integral part of the processor. Both the processor and the storage medium can reside in an Application Specific Integrated Circuit (ASIC). Alternatively, the processor and storage medium can exist as discrete components in an electronic device or host device.

[0104] Those skilled in the art will understand that all or part of the steps of the above-described method embodiments can be implemented by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When executed, the program performs the steps of the above-described method embodiments; and the aforementioned storage medium includes various media capable of storing program code, such as ROM, RAM, magnetic disks, or optical disks.

[0105] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some or all of the technical features therein. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of this application.

Claims

1. A dynamic caching method of files, characterized in that, A server applied to a distributed storage system, the distributed storage system comprising a plurality of clients and servers; the method comprising: adding the first client to an access list in response to receiving an access request of any first client accessing a target file, wherein the access list comprises at least one first client accessing the target file; if the number of first clients accessing the target file is a plurality, determining a second client from the plurality of first clients, wherein the second client is a client having a lock relationship with the target file, and the target file is stored in a local cache module of the second client; storing the target file from the local storage module of the second client into a storage server of the server, and releasing the lock relationship between the second client and the target file, so that the first client accesses the target file through the storage server; if the first client accesses the target file ends, storing the target file from the storage server to the local cache module of the second client, and re-establishing the lock relationship between the second client and the target file; in response to receiving a write instruction for the target file, determining whether the target file includes unsynchronized data; if the target file includes unsynchronized data, determining whether a plurality of new data to be written included in the write instruction has the same data as the unsynchronized data; if the plurality of new data to be written has the same data as the unsynchronized data, synchronizing the unsynchronized data to the storage server before executing the write instruction.

2. The method of claim 1, wherein, Further comprising: if the number of first clients accessing the target file is one, storing the target file from the storage server to the local cache module of the first client, and establishing the lock relationship between the first client and the target file.

3. The method of claim 2, wherein, The access request comprises cache state information of the first client; Correspondingly, before storing the target file from the storage server to the local cache module of the first client, further comprising: obtaining the cache state information of the first client; if the cache state information is cacheable state, executing the step of storing the target file from the storage server to the local cache module of the first client; if the cache state information is non-cacheable state, not executing the step of storing the target file from the storage server to the local cache module of the first client.

4. The method of claim 1, wherein, The local cache module comprises a cache unit and a flushing unit, wherein the cache unit comprises a plurality of files and corresponding lock information of each file; Correspondingly, storing the target file from the local storage module of the second client into the storage server of the server, and releasing the lock relationship between the second client and the target file, comprises: extracting the target file and the corresponding file lock information of the target file from the plurality of files included in the cache unit according to the file identifier of the target file; The target file is transferred to the storage server of the server by the lower brushing unit, and file lock information corresponding to the target file is set to an unlocked state.

5. The method of claim 4, wherein, The local cache module further comprises a recycling unit, and correspondingly, the method further comprises: acquiring the capacity of the cached files in the cache unit and the total capacity of the cache unit; if the ratio of the capacity of the cached files to the total capacity is greater than a preset ratio, querying a target file that has not been accessed within a preset time period from the cached files; the target file is deleted by the recycling unit.

6. The method of claim 4, wherein, The target file comprises a plurality of unsynchronized data; Correspondingly, the target file is transferred to the storage server of the server by the lower brushing unit, comprising: dividing the plurality of unsynchronized data into a plurality of data groups of a preset capacity; sequentially transferring each data group of the preset capacity to the storage server of the server.

7. A dynamic caching apparatus for files, characterized by The server is applied to a distributed storage system, and the distributed storage system comprises a plurality of clients and servers; the device comprises: a receiving module configured to add a target file to an access list in response to receiving an access request of any first client accessing the target file, wherein the access list comprises at least one first client accessing the target file; a determining module configured to determine a second client from a plurality of first clients if the number of first clients accessing the target file is a plurality, wherein the second client is a client having a locking relationship with the target file, and the target file is stored in a local cache module of the second client; a transferring module configured to transfer the target file from the local cache module of the second client to a storage server of the server, and release the locking relationship between the second client and the target file, so that the first client accesses the target file through the storage server; a locking module configured to re-transfer the target file from the storage server to the local cache module of the second client and re-establish the locking relationship between the second client and the target file if the first client finishes accessing the target file; a data writing module configured to determine whether the target file comprises unsynchronized data in response to receiving a write instruction for the target file; if the target file comprises unsynchronized data, determine whether a plurality of new data to be written included in the write instruction have the same data as the unsynchronized data; if the plurality of new data to be written have the same data as the unsynchronized data, synchronize the unsynchronized data to the storage server before executing the write instruction.

8. An electronic device, comprising: comprise: a processor and a memory; the memory stores computer execution instructions; the processor executes the computer execution instructions stored in the memory, so that the processor executes the file dynamic caching method according to any one of claims 1 to 6.

9. A computer storage medium, characterized in that The computer storage medium stores computer execution instructions, and when the processor executes the computer execution instructions, the file dynamic caching method according to any one of claims 1 to 6 is realized.

Citation Information

Patent Citations

  • DFS-oriented client persistent caching method and system in global namespace

    CN110750507A

  • Data server device configured to manage distributed lock of file together with client device in storage system employing distributed file system

    KR1020170090594A