File access method and electronic equipment

By cached files in the first electronic device, directly reading from the local area, the problem of long access time of multi-device files is solved, and the user experience is improved.

CN120282122AActive Publication Date: 2025-07-08HONOR DEVICE CO LTD
View PDF 9 Cites 0 Cited by

Patent Information

Application Number
CN202311869865.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-12-29
Publication Date
2025-07-08
Estimated Expiration
2043-12-29

AI Technical Summary

Technical Problem

During the multi-device file access process, the prior art leads to a longer time to read files, which is prone to lag, affecting the user experience.

Method used

By determining whether the file has been cached in the first electronic device, if cached, it will be read directly from the local area, otherwise it will be acquired and cached from the second electronic device, and the data interaction time across devices will be reduced.

Benefits of technology

Reduces the file reading time, avoids lag, and improves user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120282122A_ABST
    Figure CN120282122A_ABST
Patent Text Reader

Abstract

The embodiment of the invention is applicable to the technical field of data processing, provides a file access method and electronic equipment, is applied to first electronic equipment, and determines whether a first file stored in second electronic equipment is cached in the first electronic equipment or not by responding to first operation, and if the first file is cached in the first electronic equipment, the first file is accessed to the second electronic equipment. According to the file access method provided by the embodiment of the invention, the first file is directly read from the first electronic equipment, and data interaction between the first electronic equipment and the second electronic equipment needs a period of time, so that the process of acquiring the first file from the second electronic equipment by the first electronic equipment can be avoided by adopting the file access method provided by the embodiment of the invention; according to the invention, the time required for reading the first file is reduced, so that the jamming condition caused by long reading time is avoided, and the user experience is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of data processing, and more particularly, to a file access method and an electronic device. Background Art

[0002] With the continuous development of terminal technology, the number of electronic devices owned by people has gradually increased. To facilitate user use, generally, multiple electronic devices owned by the same user can access and obtain files from each other.

[0003] For example, user A owns both mobile phone 100 and tablet computer (portable android device, Pad) 200 at the same time. Among them, photo 201 is stored in PAD 200, and user A can access photo 201 stored in PAD 200 from mobile phone 100. In a possible situation, user A can add photo 201 to the global favorite application (Application, App) in PAD 200, and then open the global favorite App on mobile phone 100 to find photo 201 favorited in the global favorite App to read photo 201. However, each time mobile phone 100 reads photo 201, it needs to read from PAD 200, which will result in a longer time required to read photo 201 and is prone to lag, affecting the user experience.

[0004] Based on this, the problem of how to reduce the time required to access files in the peer electronic device has become an urgent problem to be solved. Summary of the Invention

[0005] This application provides a file access method that can reduce the time required to access files in the peer electronic device.

[0006] In a first aspect, a file access method is provided. The method is applied to a first electronic device and includes:

[0007] In response to a first operation, determine whether a first file is cached in the first electronic device. The first file is a file stored in a second electronic device, and the first operation is an operation to read the first file;

[0008] If the first file is cached in the first electronic device, read the first file from the first electronic device.

[0009] The file access method provided by the embodiment of the present application is applied to a first electronic device. By responding to a first operation, it is determined whether a first file stored in a second electronic device is cached in the first electronic device. If the first file is cached in the first electronic device, the first file is directly read from the first electronic device. Since there is a time period for data interaction between the first electronic device and the second electronic device, by using the file access method provided by the embodiment of the present application, the process of the first electronic device obtaining the first file from the second electronic device can be avoided, the time required to read the first file is reduced, and thus the lag situation caused by the long reading time is avoided, improving the user experience.

[0010] In combination with the first aspect, in some embodiments of the first aspect, determining whether the first file is cached in the first electronic device includes: determining first identification information of the first file; searching in the first electronic device based on the first identification information to determine whether the first file is cached in the first electronic device.

[0011] In combination with the first aspect, in some embodiments of the first aspect, searching in the first electronic device based on the first identification information to determine whether the first file is cached in the first electronic device includes: searching for a second file in the first electronic device based on the first identification information, where the identification information of the second file is the first identification information and the index information of the second file matches the index information of the first file; if the second file exists in the first electronic device, the second file is the first file.

[0012] In combination with the first aspect, in some embodiments of the first aspect, the method further includes: if the first file is not cached in the first electronic device, obtaining the first file from the second electronic device; caching the first file in the first electronic device.

[0013] The file access method provided by the embodiment of the present application, in the case where the first file is not cached in the first electronic device, obtains the first file from the second electronic device and caches the first file in the cache module of the first electronic device. In this way, the next time the first file is read, the first file can be read from the cache module of the first electronic device, avoiding the process of the first electronic device obtaining the first file from the second electronic device again, reducing the time required to read the first file the next time, and thus avoiding the lag situation caused by the long reading time, improving the user experience.

[0014] In combination with the first aspect, in certain embodiments of the first aspect, the index information of the first file matches the index information of the second file, including: the index information of the first file completely matches the index information of the second file, and the index information of the first file partially matches the index information of the second file. If the index information of the first file partially matches the index information of the second file, the first sub-file in the first file is cached in the first electronic device, where the first sub-file is the partial file in the first file whose index information matches the index information of the second file. Reading the first file from the cache module of the first electronic device includes: reading the first sub-file from the first electronic device; the method further includes: reading the second sub-file from the second electronic device, where the second sub-file is the sub-file in the first file other than the first sub-file.

[0015] In the file access method provided by the embodiments of the present application, when determining whether the index information of the first file matches the index information of the second file, if the index information of the first file partially matches the index information of the second file, the first sub-file that matches the index information of the first file is read from the first electronic device, and the second sub-file that matches the index information of the first file is read from the second electronic device, so that when the first file is partially cached in the first electronic device, the cached partial sub-files can be read. Compared with reading the first file entirely from the second electronic device, it can reduce the time required to read the first file, reduce the possibility of jamming caused by a long fetch time, and improve the user experience.

[0016] In combination with the first aspect, in certain embodiments of the first aspect, the method further includes: in response to a second operation, modifying the first file in the first electronic device, where the second operation is used to modify the first file.

[0017] In combination with the first aspect, in certain embodiments of the first aspect, the first electronic device includes a disk cache file read / write module and a disk cache data storage module. In response to a first operation, determining whether the first file is cached in the disk cache data storage module includes: in response to the first operation, the disk cache file read / write module determines whether the first file is cached in the disk cache data storage module; if the first file is cached in the first electronic device, reading the first file from the first electronic device includes: if the first file is cached in the disk cache data storage module, the disk cache file read / write module reads the first file from the disk cache data storage module.

[0018] In combination with the first aspect, in certain embodiments of the first aspect, the disk cache file read / write module determining whether the first file is cached in the disk cache data storage module includes: the disk cache file read / write module determines the first identification information of the first file; the disk cache file read / write module searches in the disk cache data storage module based on the first identification information to determine whether the first file is cached in the disk cache data storage module.

[0019] In combination with the first aspect, in some embodiments of the first aspect, the disk cache file reading and writing module searches in the disk cache data storage module based on the first identification information to determine whether the first file is cached in the disk cache data storage module, including: the disk cache file reading and writing module searches for a second file in the disk cache data storage module based on the first identification information, the identification information of the second file is the first identification information, and the index information of the second file matches the index information of the first file; if the second file exists in the disk cache data storage module, the second file is the first file.

[0020] In combination with the first aspect, in some embodiments of the first aspect, the method further includes: if the first file is not cached in the disk cache data storage module, the disk cache file reading and writing module obtains the first file from a second electronic device; the disk cache file reading and writing module caches the first file in the disk cache data storage module.

[0021] In combination with the first aspect, in some embodiments of the first aspect, the first electronic device includes a disk cache data storage module and a disk cache file reading and writing module, and the index information of the first file matches the index information of the second file, including: the index information of the first file completely matches the index information of the second file, and, the index information of the first file partially matches the index information of the second file. If the index information of the first file partially matches the index information of the second file, the first sub-file in the first file is cached in the disk cache data storage module, where the first sub-file is the partial file in the first file whose index information matches the index information of the second file. The disk cache file reading and writing module reads the first file from the disk cache data storage module, including: the disk cache file reading and writing module reads the first sub-file from the disk cache data storage module; the method further includes: the disk cache file reading and writing module reads a second sub-file from the second electronic device, and the second sub-file is the sub-file in the first file other than the first sub-file.

[0022] In combination with the first aspect, in some embodiments of the first aspect, the method further includes: in response to a second operation, the disk cache file reading and writing module modifies the first file in the disk cache data storage module, and the second operation is used to modify the first file.

[0023] In combination with the first aspect, in some embodiments of the first aspect, the disk cache file reading and writing module is further configured to determine whether the remaining space in the disk cache data storage module is less than a preset threshold during the process of modifying the first file in the disk cache data storage module, and if the remaining space in the disk cache data storage module is less than the preset threshold, send the modified first file to the second electronic device.

[0024] In connection with the first aspect, in some embodiments of the first aspect, the first electronic device further includes a disk cache upper limit management module, which is configured to determine the maximum storage space of the disk cache data storage module based on the remaining memory space of the first electronic device.

[0025] In connection with the first aspect, in some embodiments of the first aspect, the first file includes a picture file, a video file, and a document file.

[0026] In a second aspect, there is provided a file access device, including a unit configured to execute any one of the methods in the first aspect. The device may be a server, or a terminal device, or a chip within the terminal device. The device may include an input unit and a processing unit.

[0027] When the device is a terminal device, the processing unit may be a processor, and the input unit may be a communication interface; the terminal device may further include a memory, which is configured to store computer program code. When the processor executes the computer program code stored in the memory, the terminal device is caused to execute any one of the methods in the first aspect.

[0028] When the device is a chip within the terminal device, the processing unit may be a processing unit inside the chip, and the input unit may be an output interface, a pin, or a circuit, etc.; the chip may further include a memory, which may be a memory within the chip (e.g., a register, a cache, etc.), or a memory located outside the chip (e.g., a read-only memory, a random access memory, etc.); the memory is configured to store computer program code. When the processor executes the computer program code stored in the memory, the chip is caused to execute any one of the methods in the first aspect.

[0029] In a possible implementation, the memory is configured to store computer program code; a processor, which executes the computer program code stored in the memory. When the computer program code stored in the memory is executed, the processor is configured to execute: in response to a first operation, determining whether a first file is cached in a first electronic device, where the first file is a file stored in a second electronic device, and the first operation is an operation of reading the first file; if the first file is cached in the first electronic device, reading the first file from the first electronic device.

[0030] In a third aspect, there is provided a computer-readable storage medium, which stores computer program code. When the computer program code is run by a file access device, the file access device is caused to execute any one of the file access methods in the first aspect.

[0031] In a fourth aspect, a computer program product is provided, which includes computer program code that, when run on a file access device, causes the file access device to execute any of the device methods in the first aspect.

[0032] The file access method provided by the embodiments of the present application is applied to a first electronic device. By responding to a first operation, it is determined whether a first file stored in a second electronic device is cached in the first electronic device. If the first file is cached in the first electronic device, the first file is directly read from the first electronic device. Since there is a time period required for data interaction between the first electronic device and the second electronic device, by using the file access method provided by the embodiments of the present application, the process of the first electronic device obtaining the first file from the second electronic device can be avoided, the time required to read the first file is reduced, and further, the situation of lag caused by a long reading time is avoided, improving the user experience. BRIEF DESCRIPTION OF THE DRAWINGS

[0033] FIG. 1(a) is a schematic diagram of an interface for two electronic devices to log in to an account;

[0034] FIG. 1(b) is a schematic diagram of adding a file in a tablet computer to global favorites;

[0035] FIG. 1(c) is a schematic diagram of enabling global favorites;

[0036] FIG. 1(d) is a schematic diagram of the global favorites interface;

[0037] Figure 2 is a schematic diagram of the display process of enabling pictures in global favorites;

[0038] Figure 3 is a schematic diagram of the display process of enabling videos in global favorites;

[0039] Figure 4 is a schematic diagram of the display process of enabling documents in global favorites;

[0040] Figure 5 is a schematic diagram of the hardware system of an electronic device applicable to the present application;

[0041] Figure 6 is a schematic diagram of the software system of an electronic device applicable to the present application;

[0042] Figure 7 is a schematic diagram of the software system of an electronic device applicable to the present application;

[0043] Figure 8 is a schematic diagram of the structure of a file directory applicable to the present application;

[0044] Figure 9 It is a schematic diagram of a software system applicable to the electronic device of the present application;

[0045] Figure 10 It is a schematic diagram of an application scenario provided by an embodiment of the present application;

[0046] Figure 11 It is a schematic diagram of an application scenario provided by an embodiment of the present application;

[0047] Figure 12 It is a schematic diagram of an application scenario provided by an embodiment of the present application;

[0048] Figure 13 It is a schematic flowchart of a file access method provided by an embodiment of the present application;

[0049] Figure 14 It is a schematic diagram of an index information provided by an embodiment of the present application;

[0050] Figure 15 It is a schematic diagram of an index information provided by an embodiment of the present application;

[0051] Figure 16 It is a schematic diagram of a metadata information provided by an embodiment of the present application;

[0052] Figure 17 It is a schematic diagram of a metadata information provided by an embodiment of the present application;

[0053] Figure 18 It is a schematic flowchart of a file access method provided by an embodiment of the present application;

[0054] Figure 19 It is a schematic diagram of an index information provided by an embodiment of the present application;

[0055] Figure 20 It is a schematic diagram of a metadata information provided by an embodiment of the present application;

[0056] Figure 21 It is a schematic flowchart of a file access method provided by an embodiment of the present application;

[0057] Figure 22 It is a schematic diagram of an index information provided by an embodiment of the present application;

[0058] Figure 23 It is a schematic diagram of a metadata information provided by an embodiment of the present application;

[0059] Figure 24 It is a schematic flowchart of a file access method provided by an embodiment of the present application;

[0060] Figure 25 It is a schematic flowchart of a file access method provided in an embodiment of the present application;

[0061] Figure 26 It is a schematic flowchart of a file access method provided in an embodiment of the present application;

[0062] Figure 27 It is a schematic flowchart of a file access method provided in an embodiment of the present application;

[0063] Figure 28 It is a schematic diagram of a file access device provided by the present application;

[0064] Figure 29 It is a schematic diagram of an electronic device for image processing provided by the present application. Detailed implementation manners

[0065] Next, the technical solutions in the embodiments of the present application will be described with reference to the accompanying drawings in the embodiments of the present application. Among them, in the description of the embodiments of the present application, unless otherwise specified, " / " means "or". For example, A / B may mean A or B; herein, "and / or" is only a description of the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B may mean: A exists alone, A and B exist simultaneously, and B exists alone. In addition, in the description of the embodiments of the present application, "a plurality of" means two or more than two.

[0066] Hereinafter, the terms "first", "second", and "third" are only used for descriptive purposes and cannot be construed as indicating or implying relative importance or implicitly specifying the quantity of the indicated technical features. Thus, features defined with "first", "second", and "third" may explicitly or implicitly include one or more of such features.

[0067] In the embodiments of the present application, words such as "exemplary" or "for example" are used to represent examples, illustrations, or explanations. Any embodiment or design solution described as "exemplary" or "for example" in the embodiments of the present application should not be construed as being more preferred or having more advantages than other embodiments or design solutions. Rather, the use of words such as "exemplary" or "for example" is intended to present relevant concepts in a specific manner.

[0068] The global collection App is an application program that realizes file sharing among multiple electronic devices. Among them, the user logs in to multiple electronic devices with the same account, and any one of the multiple electronic devices can collect local files in the global collection App, so that other electronic devices among the multiple electronic devices can access the file through the global collection App. By using the global collection App, it is convenient for users to manage files.

[0069] Exemplarily, the user logs in to the account "1111" on both the mobile phone 100 and the PAD 200, as shown in Fig. 1(a). The user can add the photos 201, videos 202, and documents 203 in the PAD 200 to the global collection App 204, as shown in Fig. 1(b). When the user clicks to open the global collection App 204 on the mobile phone 100, as shown in Fig. 1(c). Thumbnails of the photos 201, videos 202, and documents 203 are displayed on the display frame 2041 of the global collection App 204 on the mobile phone 100, as shown in Fig. 1(d).

[0070] The user clicks on the thumbnail of photo 201, as Figure 2 shown in (a) of. In response to the user's operation of clicking on the thumbnail of photo 201, the mobile phone 100 reads photo 201 from the PAD 200. After waiting for a period of time, at this time, a loading interface is displayed on the mobile phone 100, as Figure 2 shown in (b) of. After the mobile phone 100 finishes loading photo 201, the full picture of photo 201 is displayed on the mobile phone 100, as Figure 2 shown in (c) of.

[0071] The user clicks on the thumbnail of video 202, as Figure 3 shown in (a) of. In response to the user's operation of clicking on the thumbnail of video 202, the mobile phone 100 reads video 202 from the PAD 200. After waiting for a period of time, at this time, a loading interface is displayed on the mobile phone 100, as Figure 3 shown in (b) of. After the mobile phone 100 finishes loading video 202, the full video of video 202 is displayed on the mobile phone 100, as Figure 3 shown in (c) of.

[0072] The user clicks on the thumbnail of document 203, as Figure 4 shown in (a) of. In response to the user's operation of clicking on the thumbnail of document 203, the mobile phone 100 reads document 203 from the PAD 200. After waiting for a period of time, at this time, a loading interface is displayed on the mobile phone 100, as Figure 4 shown in (b) of. After the mobile phone 100 finishes loading document 203, the content of document 203 is displayed on the mobile phone 100, as Figure 4 shown in (c) of.

[0073] However, when the mobile phone 100 reads the photos 201, videos 202, and documents 203 from the PAD 200, it usually takes a relatively long time to obtain the relevant data of the photos 201, videos 202, and documents 203 from the PAD 200. This may cause the user to experience lag when viewing the above-mentioned photos 201, videos 202, and documents 203 on the mobile phone 100, affecting the user experience.

[0074] In view of this, an embodiment of the present application provides a file access method, which is applied to a first electronic device. By responding to a first operation, it is determined whether a first file stored in a second electronic device is cached in a cache module of the first electronic device. If the first file is cached in the cache module of the first electronic device, the first file is directly read from the cache module of the first electronic device. Since there is a period of time required for data interaction between the first electronic device and the second electronic device, by using the file access method provided by the embodiment of the present application, the process of the first electronic device obtaining the first file from the second electronic device can be avoided, the time required to read the first file is reduced, and thus the lag caused by the long reading time can be avoided, improving the user experience.

[0075] The file access method provided by the embodiment of the present application can be applied to a first electronic device. Optionally, the first electronic device includes a terminal device, and the terminal device can also be referred to as a terminal, a user equipment (UE), a mobile station (MS), a mobile terminal (MT), etc. The terminal device can be a mobile phone, a smart TV, a wearable device, a tablet computer (Pad), a computer with wireless transceiver function, a virtual reality (VR) terminal device, an augmented reality (AR) terminal device, a wireless terminal in industrial control, a wireless terminal in self-driving, a wireless terminal in remote medical surgery, a wireless terminal in smart grid, a wireless terminal in transportation safety, a wireless terminal in smart city, a wireless terminal in smart home, and so on. The specific technologies and specific device forms adopted by the terminal device in the embodiments of the present application are not limited.

[0076] Exemplarily, Figure 5The structural schematic diagram of the first electronic device 100 is shown. The first electronic device 100 may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, a headphone interface 170D, a sensor module 180, a button 190, a motor 191, an indicator 192, a camera 193, a display screen 194, and a subscriber identification module (SIM) card interface 195, etc. The sensor module 180 may include a pressure sensor 180A, a gyroscope sensor 180B, a barometric pressure sensor 180C, a magnetic sensor 180D, an acceleration sensor 180E, a distance sensor 180F, a proximity light sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, an ambient light sensor 180L, a bone conduction sensor 180M, etc.

[0077] It can be understood that the structure schematically shown in the embodiments of this application does not constitute a specific limitation on the electronic device 100. In other embodiments of this application, the electronic device 100 may include more or fewer components than those shown in the figure, or combine certain components, or split certain components, or have different component arrangements. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.

[0078] The processor 110 may include one or more processing units. For example, the processor 110 may include an application processor (AP), a modem processor, a graphics processing unit (GPU), an image signal processor (ISP), a controller, a memory, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU), etc. Among them, different processing units may be independent devices or integrated in one or more processors.

[0079] It can be understood that the interface connection relationships between the modules illustrated in the embodiments of the present application are only illustrative descriptions and do not constitute a structural limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may also adopt different interface connection methods in the above embodiments, or a combination of multiple interface connection methods.

[0080] The electronic device 100 realizes the display function through the GPU, the display screen 194, and the application processor, etc. The GPU is a microprocessor for image processing, and is connected to the display screen 194 and the application processor. The GPU is used to execute mathematical and geometric calculations for graphics rendering. The processor 110 may include one or more GPUs, which execute program instructions to generate or change display information.

[0081] The display screen 194 is used to display images, videos, etc. The display screen 194 includes a display panel. The display panel may adopt a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), a MiniLED, a MicroLED, a Micro-OLED, a quantum dot light-emitting diode (QLED), etc. In some embodiments, the electronic device 100 may include 1 or N display screens 194, where N is a positive integer greater than 1.

[0082] The electronic device 100 can realize the shooting function through the ISP, the camera 193, the video codec, the GPU, the display screen 194, and the application processor, etc.

[0083] The external memory interface 120 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device 100. The external memory card communicates with the processor 110 through the external memory interface 120 to realize the data storage function. For example, files such as music and videos are saved in the external memory card.

[0084] The internal memory 121 can be used to store computer-executable program code, and the executable program code includes instructions. The processor 110 executes various functional applications and data processing of the electronic device 100 by running the instructions stored in the internal memory 121. The internal memory 121 can include a program storage area and a data storage area. Among them, the program storage area can store the operating system, application programs required for at least one function (such as the sound playback function, the image playback function, etc.). The data storage area can store the data created during the use of the electronic device 100 (such as audio data, phone book, etc.). In addition, the internal memory 121 can include high-speed random access memory, and can also include non-volatile memory, such as at least one disk storage device, a flash memory device, a universal flash storage (UFS), etc.

[0085] The electronic device 100 can implement audio functions through the audio module 170, the speaker 170A, the receiver 170B, the microphone 170C, the headphone jack 170D, and the application processor, etc. Such as music playback, recording, etc.

[0086] It should be noted that any electronic device mentioned in the embodiments of the present application may include more or fewer modules in the electronic device 100.

[0087] Files are shared between the first electronic device and the second electronic device. Among them, the structure of the second electronic device is similar to that of the first electronic device, and details are not elaborated here.

[0088] The software system of the first electronic device 100 can adopt a layered architecture, an event-driven architecture, a microkernel architecture, a microservices architecture, or a cloud architecture. In the embodiments of the present application, taking the Android system with a layered architecture as an example, the software structure of the first electronic device 100 is exemplarily described.

[0089] Figure 6 It is the software structure block diagram of the first electronic device 100 in the embodiments of the present application.

[0090] The layered architecture of the first electronic device 100 divides the software into several layers, and each layer has a clear role and division of labor. The layers communicate with each other through software interfaces. In some embodiments, the Android system is divided into four layers, from top to bottom are the application layer, the application framework layer, the Android runtime and the system libraries, and the kernel layer.

[0091] The application layer can include a series of application program packages.

[0092] Such as Figure 6 shown, the application program packages can include applications such as global favorites, distributed file client modules, etc.

[0093] Among them, the distributed file client module may include a message sending and receiving module, a metadata management module, a file management module, and a disk storage module.

[0094] Among them, in a possible case, as Figure 7 shown, the disk storage module may include a disk cache logic module and a disk cache storage module. The disk cache logic module may include a disk cache upper limit management module, a disk cache file read / write module, and a disk cache cleaning module; the disk cache storage module may include a disk cache metadata storage module and a disk cache data storage module.

[0095] Among them, the disk cache logic module may be used to manage the upper limit of the disk cache, clean the cache, and manage the read / write logic of the cache file. The disk cache storage module may be used to save the metadata and files of the files read from the distributed file server of another electronic device.

[0096] Next, the specific structure of the disk cache storage module and the storage form of the stored files will be introduced.

[0097] Each file stored in the disk cache storage module has a unique ID. Exemplarily, as shown in Table 1, the ID of the files stored in the disk cache storage module may include 32 bits, where the first 6 bits of the ID may be used to indicate the file type of the file, and the last 26 bits of the ID may be an unsigned integer generated by hashing the absolute file path.

[0098] Table 1

[0099]

[0100] The files stored in the disk cache storage module may be stored in a three-level directory, as Figure 8 shown. Among them, the first-level directory is represented by 6 bits of the file type, the second-level directory is represented by the middle 14 bits, and the third-level directory is represented by the last 16 bits. The cache data of each file is stored in files named index and default respectively. Among them, the index file stores the cache file index information, stores the specific file segments of the file cached locally, and the modification information of the file, etc. The specific fields are shown in Table 2. The default file stores the file content of the cache file, which corresponds exactly to the file content stored in the server electronic device. It should be understood that the index information is read from the local cache into the memory when the service starts and saved to the local cache when the service is destroyed.

[0101] Table 2

[0102] Type Information 16-bit unsigned integer Version number 16-bit unsigned integer Whether data has been written 64-bit unsigned integer Cache file size 64-bit unsigned integer Written data size 64-bit unsigned integer File partial fragment size (read index information) 64-bit unsigned integer File partial fragment offset (read index information) 64-bit unsigned integer File partial fragment offset (write index information) 64-bit unsigned integer File partial fragment offset (write index information)

[0103] The disk cache metadata storage module is used to cache file metadata information. The cached file metadata information can be as shown in Table 3, including version number, file ID, last access time, and last modification time. The file metadata information is read from the local cache into memory when the service starts, and saved to the local cache when the service is destroyed.

[0104] Table 3

[0105] Type Information 16-bit unsigned integer Version number 16-bit unsigned integer Whether to keep this file 32-bit unsigned integer File ID 64-bit unsigned integer File last access time 64-bit unsigned integer File last modification time

[0106] The disk cache upper limit management module is used to manage the disk cache upper limit, and adjusts the maximum remaining space of the disk cache based on the remaining space of the mobile phone disk.

[0107] For example:

[0108] When the remaining space of the mobile phone disk is greater than 10GB, the upper limit of the disk cache is set to 2GB;

[0109] When the remaining space of the mobile phone disk is less than 10GB and greater than 5GB, the upper limit of the disk cache is set to 10% of the remaining space of the mobile phone disk;

[0110] When the remaining space of the mobile phone disk is less than 5GB, the upper limit of the disk cache is set to 0GB.

[0111] The application framework layer provides application programming interfaces (APIs) and programming frameworks for the applications in the application layer. The application framework layer includes some predefined functions.

[0112] Such as Figure 6 shown, the application framework layer can include the Portable Operating System Interface (POSIX), etc.

[0113] Android Runtime includes core libraries and a virtual machine. Android runtime is responsible for the scheduling and management of the Android system.

[0114] The core libraries contain two parts: one part is the functional functions that need to be called by the Java language, and the other part is the core libraries of Android.

[0115] The application layer and the application framework layer run in the virtual machine. The virtual machine executes the Java files of the application layer and the application framework layer as binary files. The virtual machine is used to perform functions such as object lifecycle management, stack management, thread management, security and exception management, and garbage collection.

[0116] The system library may include multiple functional modules. For example: a surface manager, Media Libraries, a 3D graphics processing library (such as OpenGL ES), a 2D graphics engine (such as SGL), etc., which are not shown in the figure.

[0117] The kernel layer is the layer between hardware and software. The kernel layer may include a linux kernel module, a FUSE user-space file system framework module, etc.

[0118] The global collection in the application layer can sequentially call the distributed file client module through POSIX, the linux kernel module, and the FUSE user-space file system framework module to access the distributed file server module on another electronic device, realizing file sharing between two electronic devices.

[0119] It should be noted that the first electronic device mentioned in the embodiments of the present application may include more or fewer modules in the above-mentioned electronic devices.

[0120] The software system of the second electronic device 200 may adopt a layered architecture, an event-driven architecture, a microkernel architecture, a microservices architecture, or a cloud architecture. Among them, similar to the first electronic device 100, the Android system is divided into four layers, from top to bottom are the application layer, the application framework layer, the Android runtime, the system library, and the kernel layer.

[0121] The application layer may include a series of application packages.

[0122] As Figure 9 shown, the application packages may include applications such as global collection and distributed file server module.

[0123] Among them, the distributed file server module includes a message transceiver module and a file operation processing module.

[0124] The application framework layer provides application programming interfaces (APIs) and programming frameworks for the applications in the application layer. The application framework layer includes some predefined functions.

[0125] As Figure 9 shown, the application framework layer may include standard POSIX interfaces, etc.

[0126] Android Runtime includes core libraries and a virtual machine. Android runtime is responsible for the scheduling and management of the Android system.

[0127] The core library consists of two parts: one is the functional functions that need to be called by the Java language, and the other is the core library of Android.

[0128] The application layer and the application framework layer run in the virtual machine. The virtual machine executes the Java files in the application layer and the application framework layer as binary files. The virtual machine is used to perform functions such as management of object life cycles, stack management, thread management, security and exception management, and garbage collection.

[0129] The system library can include multiple functional modules. For example: surface manager, Media Libraries, 3D graphics processing library (e.g., OpenGL ES), 2D graphics engine (e.g., SGL), etc., which are not shown in the figure.

[0130] The kernel layer is the layer between the hardware and the software. The kernel layer includes the local file system module, etc.

[0131] It should be noted that the second electronic device mentioned in the embodiments of the present application may include more or fewer modules in the above-mentioned electronic devices.

[0132] It should be understood that the software framework layers of the above-mentioned first electronic device and the second electronic device are only examples. Since the first electronic device and the second electronic device may include more or fewer modules, in a possible case, the architectures in the software framework layers of the first electronic device and the second electronic device may be the same, and the embodiments of the present application do not limit this.

[0133] It should be understood that the first electronic device can perform data transmission with the message receiving and sending module in the distributed file server module in the application layer of the second electronic device through the message receiving and sending module in the distributed file client module in the application layer, so as to realize file sharing between the first electronic device and the second electronic device.

[0134] The application scenarios provided by the embodiments of the present application will be described below with reference to the accompanying drawings.

[0135] As shown in Figure 1(a), the user has logged in to the account "1111" on both the mobile phone 100 and the PAD 200. The user can add the photos 201, videos 202, and documents 203 in the PAD 200 to the global favorite App 204, as shown in Figure 1(b). When the user clicks to open the global favorite App 204 on the 100, as shown in Figure 1(c). Thumbnails of the photos 201, videos 202, and documents 203 are displayed on the display box 2041 of the global favorite App 204 in the mobile phone 100, as shown in Figure 1(d).

[0136] The user clicks on the thumbnail of the photo 201, as Figure 10as shown in (a) of. In response to the user's operation of clicking on the thumbnail of photo 201, mobile phone 100 directly reads photo 201 cached in mobile phone 100 and displays the full picture of photo 201 on mobile phone 100, as Figure 10 shown in (b) of. During the process of reading photo 201, there is no need to wait to read photo 201 from PAD 200.

[0137] The user clicks on the thumbnail of video 202, as Figure 11 shown in (a) of. In response to the user's operation of clicking on the thumbnail of video 202, mobile phone 100 directly reads video 202 cached in mobile phone 100 and displays the full video of video 202 on mobile phone 100, as Figure 11 shown in (b) of. During the process of reading video 202, there is no need to wait to read video 202 from PAD 200.

[0138] The user clicks on the thumbnail of document 203, as Figure 12 shown in (a) of. In response to the user's operation of clicking on the thumbnail of document 203, mobile phone 100 directly reads document 203 cached in mobile phone 100 and displays the content of document 203 on mobile phone 100, as Figure 12 shown in (b) of. During the process of reading document 203, there is no need to wait to read document 203 from PAD 200. In one possible case, as Figure 12 shown in (c) of, the user modifies document 203 in mobile phone 100. Then mobile phone 100 will send the updated document 203 to PAD 200 so that the document 203 stored in PAD 200 is also the updated document 203, as Figure 12 shown in (d) of.

[0139] It should be understood that the above is an example illustration of the application scenario and does not impose any limitation on the application scenario of the present application.

[0140] Next, in combination with Figures 13 to 27 a detailed description of the file access method provided by the embodiments of the present application will be given.

[0141] For ease of understanding, in the following embodiments, it is assumed that the first electronic device refers to the above-mentioned mobile phone 100 and the second electronic device refers to the above-mentioned PAD 200 for illustration.

[0142] First, the access by mobile phone 100 to picture A stored in PAD 200 will be described through the Figure 13 embodiments shown.

[0143] It should be noted that the picture data is usually small, so the mobile phone 100 can obtain all the picture data at one time, and there is usually no situation where only part of the picture data is cached in the mobile phone 100. It can be understood that Figure 13 The illustrated embodiment is only an example, and the embodiments of the present application do not limit the types of files to be accessed. Through Figure 13 the illustrated embodiment, the mobile phone 100 can access files with relatively small file data.

[0144] Figure 13 is a schematic flowchart of a file access method provided by an embodiment of the present application. As Figure 13 shown, the method includes:

[0145] S11. Receive the user's first operation.

[0146] Among them, the first operation may refer to the operation of the user clicking on the thumbnail of Picture A in the global collection App in the mobile phone 100. It can be understood that the first operation may be the above-mentioned click operation, or the operation of opening Picture A in the global collection App in the mobile phone 100 through a voice command, or the operation of opening Picture A in the global collection App in the mobile phone 100 through a command in other ways. The embodiments of the present application do not limit this.

[0147] S12. In response to the first operation, the global collection App sends a retrieval request to the Linux kernel module.

[0148] Among them, the retrieval request is used to obtain the storage address information of the above Picture A. It can be understood that the global collection App cannot directly send a message to the message receiving and sending module in the distributed file client module, and can only send a message to the distributed file client module through the Linux kernel module and the FUSE user-mode file system framework module.

[0149] S13. The Linux kernel module sends a retrieval request to the FUSE user-mode file system framework module.

[0150] S14. The FUSE user-mode file system framework module sends a retrieval request to the file management module.

[0151] S15. The file management module sends a retrieval request to the message receiving and sending module in the mobile phone 100.

[0152] S16. The message receiving and sending module in the mobile phone 100 sends a retrieval request to the message receiving and sending module in the PAD 200.

[0153] Among them, the message sending and receiving module in the distributed file client module can send messages to the message sending and receiving module in the distributed file server module. Therefore, for message passing between the mobile phone 100 and the PAD 200, it needs to be passed from the message sending and receiving module in the mobile phone 100 to the message sending and receiving module in the PAD 200.

[0154] S17. The message sending and receiving module in the PAD 200 sends a retrieval request to the file operation processing module.

[0155] S18. The file operation processing module sends a retrieval request to the local file system module.

[0156] S19. In response to the retrieval request, the local file system module retrieves the file handle corresponding to Picture A.

[0157] It can be understood that the file handle corresponding to Picture A may be a pointer to the storage address of Picture A. Through the file handle corresponding to Picture A, the storage address of Picture A can be determined.

[0158] S110. The local file system module returns the file handle corresponding to Picture A to the file operation processing module.

[0159] S111. The file operation processing module returns the file handle corresponding to Picture A to the message sending and receiving module in the PAD 200.

[0160] S112. The message sending and receiving module in the PAD 200 returns the file handle corresponding to Picture A to the message sending and receiving module in the mobile phone 100.

[0161] S113. The message sending and receiving module in the mobile phone 100 returns the file handle corresponding to Picture A to the file management module.

[0162] S114. The file management module returns the file handle corresponding to Picture A to the FUSE user-space file system framework module.

[0163] S115. The FUSE user-space file system framework module returns the file handle corresponding to Picture A to the Linux kernel module.

[0164] S116. The Linux kernel module returns the file handle corresponding to Picture A to the global collection App.

[0165] S117. The global collection App generates a read request for retrieving Picture A based on the file handle corresponding to Picture A.

[0166] It can be understood that the process of retrieving Picture A may be to read all the data of Picture A from the PAD 20 in multiple times according to the file size of Picture A. Each time of reading data can refer to the following steps from S118 to S149.

[0167] S118. The Global Collection App sends a read request to the Linux kernel module.

[0168] Among them, the read request is used to read the above-mentioned Picture A. It can be understood that the Global Collection App cannot directly send a message to the message transceiver module in the distributed file client module, and can only send a message to the distributed file client module through the Linux kernel module and the FUSE user-space file system framework module.

[0169] The process of the Global Collection App reading Picture A can be to read the file fragments of Picture A in multiple times to obtain the complete file data of Picture A. The file handle corresponding to Picture A is used to indicate the storage address of Picture A. Therefore, the Global Collection App can determine the starting address and data size of each file fragment of Picture A to be read based on the file handle. The Global Collection App can carry the starting address and data size of the file fragment of Picture A in the read request and send it to the disk cache file read / write module.

[0170] S119. The Linux kernel module sends a read request to the FUSE user-space file system framework module.

[0171] S120. The FUSE user-space file system framework module sends a read request to the file management module.

[0172] S121. The file management module sends a read request to the disk cache upper limit management module.

[0173] S122. The disk cache upper limit management module determines whether the remaining space of the disk cache is greater than a preset threshold based on the read request.

[0174] If the remaining space of the disk cache is greater than the preset threshold, then execute S123. The determination of the preset threshold can refer to the above-mentioned management rules of the disk cache upper limit management module for the disk cache upper limit, that is, based on the remaining space of the mobile phone disk to adjust the maximum remaining space (equivalent to the preset threshold) of the disk cache.

[0175] S123. The disk cache upper limit management module sends a read request to the disk cache file read / write module.

[0176] S124. The disk cache file read / write module determines whether the file data corresponding to Picture A is stored in the disk cache data storage module based on the read / write request.

[0177] It can be understood that if the mobile phone 100 does not read the file data of picture A, the disk cache data storage module does not store the file data corresponding to picture A. Therefore, the mobile phone 100 can first obtain the file data of picture A from the PAD 200. For example, the file data of picture A can be obtained from the PAD 200 through the following steps S125 to S137.

[0178] The disk cache file read / write module can determine whether the file data corresponding to picture A is stored in the disk cache data storage module according to the unique ID of picture A. Among them, the unique ID of picture A is stored in the disk cache metadata storage module, and the disk cache file read / write module can determine whether the file data of picture A is stored in the disk cache data module according to whether the ID of picture A is in the disk cache metadata storage module. It can be understood that the unique ID of picture A can be Figure 7 the unique ID recorded in the three-level directory tree shown. The unique ID of picture A can be called the identification information of picture A.

[0179] Exemplarily, if the mobile phone 100 reads the file data of picture A for the first time, the file index information of picture A is usually the initial index information, and the initial index information is empty, as Figure 14 shown in the initial index information. Among them, the assignment "5" on the left side of the first line indicates that the disk cache version number is "5", the assignment "0" on the right side of the first line indicates that no data has been written to this file, the "0" in the second line indicates that the size of the file data of picture A stored in the disk cache data storage module is 0, and the assignment "0" in the third line indicates that the size of the written file data corresponding to picture A stored in the disk cache data storage module is 0.

[0180] The file data size of picture A is 3,657,728 bits (bite). The mobile phone 100 can obtain the file data of picture A through 4 reads, and each read is 1,048,576 bite of data. When reading the file segment of picture A for the first time, the disk cache file read / write module determines from the read request that the starting position of the file segment of picture A read this time is 0, and the read file size is 1,048,576 bite. That is to say, the index information of the first read of the file segment of picture A is (0, 1,048,576). It can be seen that the index information of the first read of the file segment of picture A is different from the initial index information. The disk cache file read / write module can determine that the file data corresponding to picture A is not stored in the disk cache data storage module based on the fact that the index information of the read file segment of picture A is different from the initial index information. It can be understood that the fact that the index information of the read file segment of picture A is different from the initial index information can be called a miss in reading the file segment of picture A.

[0181] After reading the file segment of Picture A, an assignment of "(0, 1048576)" is added to the file index information of Picture A, as Figure 14 shown in the first index information. It should be noted that after successfully reading the first file segment of Picture A, the assignment in the second row of the index information changes from "0" to "1048576", indicating that 1048576 bytes of data have been stored in the disk cache data storage module. The first index information can be used as the comparison index information when reading the second file segment of Picture A.

[0182] Similar to the first reading of the file segment of Picture A, when reading the second file segment of Picture A, the starting position of the file segment of Picture A read is 1048576, and the read file size is 1048576 bytes. That is to say, the index information for the second reading of the file segment of Picture A is (1048576, 1048576). Compared with the first index information, it can be seen that the second index information is different from the first index information, that is to say, the second reading of the file segment of Picture A misses, and the second reading of the file segment of Picture A is not stored in the disk cache data storage module either.

[0183] After completing the second reading of the file segment of Picture A, an assignment of "(1048576, 1048576)" is added to the file index information of Picture A. Similarly, the assignment in the second row of the index information changes from "1048576" to "2097152", indicating that 2097152 bytes of data have been stored in the disk cache data storage module, as Figure 14 shown in the second index information. The second index information can be used as the comparison index information when reading the third file segment of Picture A.

[0184] When reading the third file segment of Picture A, the starting position of the file segment of Picture A read is 2097152, and the read file size is 1048576 bytes. That is to say, the index information for the third reading of the file segment of Picture A is (1048576, 1048576). Compared with the second index information, it can be seen that the third index information is different from the second index information, that is to say, the third reading of the file segment of Picture A misses, and the third reading of the file segment of Picture A is not stored in the disk cache data storage module either.

[0185] After completing the third reading of the file segment of Picture A, based on the second index information, the file index information of Picture A adds another assignment of "(2097152, 1048576)". Similarly, the assignment in the second row of the index information changes from "2097152" to "3145728", indicating that 3145728 bytes of data have been stored in the disk cache data storage module, as shown in Figure 14 the third index information shown. The third index information can be used as the comparison index information when reading the file segment of Picture A for the fourth time.

[0186] After the fourth reading of the file segment of Picture A, the mobile phone 100 completes the reading of the file of Picture A. Since it is the last time to read the file segment of Picture A, only the remaining file data of File A is read, and the amount of data read is usually small. For example, 512000 bytes of data are read in the fourth time. The starting position of the file segment of Picture A read in the fourth time is 3145728, and the file size read is 512000 bytes. That is to say, the index information of the file segment of Picture A read in the fourth time is (3145728, 512000). Compared with the third index information, it can be seen that the fourth index information is different from the third index information, that is to say, the reading of the file segment of Picture A in the fourth time misses, and the file segment of Picture A read in the fourth time is not stored in the disk cache data storage module.

[0187] After completing the fourth reading of the file segment of Picture A, based on the third index information, the file index information of Picture A adds another assignment of "(3145728, 51200)", indicating that the file segment of Picture A read this time is a file segment with a starting address of 3145728 and a file size of 51200. Similarly, the assignment in the second row of the index information changes from "3145728" to "3657728", indicating that 3657728 bytes of data have been stored in the disk cache data storage module. The final file index information of Picture A is as shown in Figure 14 shown.

[0188] The disk cache file read / write module can store the final file index information of Picture A in the disk cache data storage module. When reading Picture A again, the index information of Picture A stored in the disk cache data storage module is used as the comparison benchmark to determine whether the reading of the file segment of Picture A again hits, that is, to determine whether the file segment of Picture A is stored in the disk cache data storage module.

[0189] If the file data of Picture A is read again, for example, when the file data of Picture A is read for the second time, the file data corresponding to Picture A may be stored in the disk cache data storage module. Therefore, the mobile phone 100 can directly obtain the file data of Picture A from the disk cache data storage module. For example, the file data of Picture A can be directly obtained from the disk cache data storage module through the following steps S140 to S142.

[0190] Exemplarily, when the file data of Picture A is read for the second time, the index information of Picture A stored in the disk cache data storage module is the initial index information as shown in Figure 15 That is, the final index information generated when the file data of Picture A is read for the first time.

[0191] When the file segment of Picture A is read for the first time, the disk cache file read / write module determines from the read request that the starting position of the file segment of Picture A read this time is 0, and the read file size is 1048576. When reading the file segment of Picture A, an assignment of "(0, 1048576)" is added to the file index information of Picture A, as shown in Figure 14 The first index information shown. It can be seen that the index information of the first read of the file segment of Picture A is the same as the initial index information. The disk cache file read / write module can determine that the file data corresponding to Picture A is stored in the disk cache data storage module based on the fact that the index information of the read file segment of Picture A is the same as the initial index information. The disk cache file read / write module can directly read the file segment with a starting position of 0 and a read file size of 1048576 from the disk cache data storage module.

[0192] Similar to the first read of the file segment of Picture A, when the file segment of Picture A is read for the second time, the index information of the read file segment of Picture A is "(1048576, 1048576)", indicating that the file segment of Picture A read this time is a file segment with a starting address of 1048576 and a file size of 1048576. It can be seen that the index information of the second read of the file segment of Picture A is also the same as the initial index information, that is to say, the second read of the file segment of Picture A hits, and the second read of the file segment of Picture A is also stored in the disk cache data storage module. The disk cache file read / write module can directly read the file segment with a starting position of 1048576 and a read file size of 1048576 from the disk cache data storage module.

[0193] When reading the file segment of Picture A for the third time, the index information of the file segment of Picture A being read is "(2097152, 1048576)", indicating that the file segment of Picture A read this time is the file segment with a starting address of 2097152 and a file size of 1048576. It can be seen that the index information of the file segment of Picture A read for the third time is the same as the initial index information, that is to say, the file segment of Picture A read for the third time hits, and the file segment of Picture A read for the third time is also stored in the disk cache data storage module. The disk cache file reading and writing module can directly read the file segment with a starting position of 2097152 and a read file size of 1048576 from the disk cache data storage module.

[0194] After reading the file segment of Picture A for the fourth time, the mobile phone 100 completes the file reading of Picture A. Since this is the last time to read the file segment of Picture A, only the remaining file data of File A is read, and the amount of data read is usually small. For example, 512000 bytes of data are read for the fourth time. Therefore, when reading the file segment of Picture A for the fourth time, the index information of the file segment of Picture A being read is "(3145728, 51200)", indicating that the file segment of Picture A read this time is the file segment with a starting address of 3145728 and a file size of 51200. It can be seen that the index information of the file segment of Picture A read for the fourth time is the same as the initial index information, that is to say, the file segment of Picture A read for the fourth time hits, and the file segment of Picture A read for the fourth time is also stored in the disk cache data storage module. The disk cache file reading and writing module can directly read the file segment with a starting position of 3145728 and a read file size of 51200 from the disk cache data storage module.

[0195] S125. The disk cache file reading and writing module sends a read request to the message sending and receiving module in the mobile phone 100.

[0196] S126. The message sending and receiving module in the mobile phone 100 sends a read request to the message sending and receiving module in the PAD 200.

[0197] S127. The message sending and receiving module in the PAD 200 sends a read request to the file operation processing module.

[0198] S128. The file operation processing module sends a read request to the local file system module.

[0199] S129. In response to the read request, the local file system module obtains the file data corresponding to Picture A.

[0200] S130. The local file system module returns the file data of Picture A to the file operation processing module.

[0201] S131. The file operation processing module returns the file data of Picture A to the message sending and receiving module in PAD 200.

[0202] S132. The message sending and receiving module in PAD 200 sends the file data of Picture A to the message sending and receiving module in mobile phone 100.

[0203] S133. The message sending and receiving module in mobile phone 100 sends the file data of Picture A to the disk cache file reading and writing module.

[0204] S134. The disk cache file reading and writing module sends an update request for updating metadata information to the disk cache metadata storage module.

[0205] S135. The disk cache metadata storage module updates the metadata information.

[0206] S136. The disk cache metadata storage module sends an indication message indicating the successful update of the metadata information to the disk cache file reading and writing module.

[0207] S137. The disk cache file reading and writing module writes the file data of Picture A to the disk cache data storage module.

[0208] S138. The disk cache data storage module updates the index information of Picture A.

[0209] In this way, when reading the file data of Picture A again, the file index information in the disk cache data storage module can be compared with the starting address and file size carried in the read request to determine whether the disk cache data storage module stores the file data of Picture A.

[0210] S139. The disk cache data storage module sends an indication message indicating the successful writing of the file data of Picture A to the disk cache file reading and writing module.

[0211] S140. The disk cache file reading and writing module determines whether the file data of Picture A stored in the disk cache data storage module is valid.

[0212] If the file data of Picture A stored in the disk cache data storage module is invalid and is not the file data of Picture A that can be read, then execute S141.

[0213] If the file data of Picture A stored in the disk cache data storage module is valid and is the file data of Picture A that can be read, then execute S142.

[0214] S141. The disk cache file reading and writing module deletes the invalid file data of Picture A stored in the disk cache data storage module.

[0215] The disk cache file reading and writing module deletes the file data of the invalid picture A stored in the disk cache data storage module, and will obtain the file data of picture A from the PAD 200. For example, the file data of picture A is obtained from the PAD 200 through the steps from S125 to S133.

[0216] S142. The disk cache file reading and writing module obtains the file data of picture A from the disk cache data storage module.

[0217] S143. Based on the received file data of picture A, the disk cache file reading and writing module sends an update request to the disk cache metadata storage module.

[0218] Among them, the update request is used to update the metadata corresponding to the file data of picture A.

[0219] S144. The disk cache metadata storage module updates the metadata information based on the update request.

[0220] When the file data of picture A is read for the first time, the initial metadata corresponding to picture A stored in the disk cache metadata storage module is as Figure 16 shown in the initial metadata, where the assignment "5" on the left side of the first line represents the disk cache version number, the assignment "120449160" in the second line represents the unique ID value of picture A, the assignment in the third line is "0", indicating that the file data of picture A has not been accessed yet, and the assignment in the fourth line is "0", indicating that the file data of picture A has not been modified yet.

[0221] As shown in the steps of S124 above, the disk cache reading module can read the file data of picture A in 4 times.

[0222] When the file segment of picture A is read for the first time, the assignment in the third line of the metadata of picture A is updated from "0" to "1701412556", indicating that the access time of the first read of the file segment of picture A is "1701412556"; the assignment in the fourth line is updated from "0" to "1701412336", indicating that the modification time of the first read of the file segment of picture A is "1701412336". It should be understood that the time can be represented by the count value of the timer in the electronic device. That is to say, the above "1701412556" and "1701412336" can be the count values of the counter in the mobile phone 100.

[0223] When the file segment of picture A is read for the second time, the third time, and the fourth time, the change of the assignment of the metadata can be referred to Figure 16As shown, the access time and modification time of the file segment of Picture A are recorded each time, which will not be elaborated here. The final metadata of Picture A can be the metadata generated after the file data of Picture A is read, that is, the fourth metadata. The fourth metadata can be stored in the disk cache metadata storage module as the initial metadata when the file data of Picture A is read next time.

[0224] When the file data of Picture A is read again, for example, when the file data of Picture A is read for the second time, the initial metadata corresponding to Picture A stored in the disk cache metadata storage module is as Figure 17 shown in the initial metadata, that is, the final metadata when the file data of Picture A was read last time. During the process of reading the file segment of Picture A each time, the assignment change of the metadata can refer to Figure 17 As shown, the access time and modification time of the file segment of Picture A are recorded each time, which will not be elaborated here.

[0225] S145. The disk cache metadata storage module returns an indication message to the disk cache file read / write module indicating that the disk cache metadata storage module has updated the metadata information.

[0226] Among them, the indication message is used to indicate that the disk cache metadata storage module has updated the metadata information.

[0227] S146. The disk cache file read / write module returns the file data of Picture A to the disk cache upper limit management module.

[0228] S147. The disk cache upper limit management module returns the file data of Picture A to the file management module.

[0229] S148. The file management module returns the file data of Picture A to the FUSE user-mode file system framework module.

[0230] S149. The FUSE user-mode file system framework module returns the file data of Picture A to the Linux kernel module.

[0231] S150. The Linux kernel module returns the file data of Picture A to the global collection App.

[0232] S151. The global collection App displays Picture A.

[0233] Next, the access of the mobile phone 100 to the video B stored in the PAD 200 will be described through the Figure 18 illustrated embodiments.

[0234] It should be noted that video data is usually large. In a possible scenario, the mobile phone 100 cannot obtain all the video data at once, so there is a situation where only part of the video data is cached in the mobile phone 100. It can be understood that Figure 18 The illustrated embodiments are merely examples, and the embodiments of the present application do not limit the types of files accessed.

[0235] Figure 18 is a schematic flowchart of a file access method provided by an embodiment of the present application. As Figure 18 shown, the method includes:

[0236] S21. Receive the second operation of the user.

[0237] Among them, the second operation may refer to the operation of the user clicking on the thumbnail of Video B in the global collection App in the mobile phone 100. It can be understood that the first operation may be the above-mentioned click operation, or the operation of opening Video B in the global collection App in the mobile phone 100 through a voice command, or the operation of opening Video B in the global collection App in the mobile phone 100 through a command in other ways. The embodiments of the present application do not limit this.

[0238] S22. In response to the second operation, the global collection App sends a retrieval request to the PAD 200.

[0239] Among them, the retrieval request is used for the storage address information of the above-mentioned Video B. The global collection App may successively send the above-mentioned retrieval request to the message receiving and sending module in the PAD 200 through the Linux kernel module, the FUSE user-space file system framework module, the file management module, and the message receiving and sending module in the mobile phone 100. The process of the global collection App sending a retrieval request to the PAD 200 is similar to the steps shown in S12 to S18, and will not be elaborated here.

[0240] S23. The PAD 200 sends the file handle of Video B to the global collection App based on the retrieval request.

[0241] The PAD 200 may successively send the file handle of Video B through the message receiving and sending module in the PAD 200, the message receiving and sending module in the mobile phone 100, the file management module, the FUSE user-space file system framework module, and the Linux kernel module. The specific process of the PAD 200 sending the file handle of Video B to the global collection App based on the retrieval request is similar to the steps shown in S19 to S117, and will not be elaborated here.

[0242] S24. The global collection App sends a read request to the disk cache upper limit management module.

[0243] Among them, the read request is used to read the above-mentioned Video B. The process of the Global Collection App reading Video B can be to read the file fragments of Video B in multiple times to obtain the file data of the complete Video B. The file handle corresponding to Video B is used to indicate the storage address of Video B. Therefore, the Global Collection App can determine the start address and data size of each file fragment of Video B to be read based on the file handle. The Global Collection App can carry the start address and data size of the file fragment of Video B in the read request and send it to the disk cache file read / write module.

[0244] S25. The disk cache upper limit management module determines whether the remaining space of the disk cache is greater than a preset threshold based on the read request.

[0245] If the remaining space of the disk cache is greater than the preset threshold, then execute S26.

[0246] S26. The disk cache upper limit management module sends the read request to the disk cache file read / write module.

[0247] S27. The disk cache file read / write module determines whether the file data corresponding to Video B is stored in the disk cache data storage module based on the read / write request.

[0248] If the file data corresponding to Video B is stored in the disk cache data storage module, then execute S28.

[0249] If the file data corresponding to Video B is not stored in the disk cache data storage module, then obtain the file data corresponding to Video B from the PAD 200. Among them, obtaining the file data corresponding to Video B from the PAD 200 is similar to obtaining the file data corresponding to Picture A from the PAD 200, that is, the steps shown in the above S125 to S139, which will not be elaborated here.

[0250] S28. The disk cache file read / write module determines whether the file data of Video B stored in the disk cache data storage module is valid.

[0251] The disk cache file read / write module can determine whether the file data of Video B stored in the disk cache data storage module is valid by whether the last modification time of the file data of Video B stored in the disk cache data storage module is consistent with the last modification time of the corresponding metadata. If the last modification time of the file data of Video B stored in the disk cache data storage module is consistent with the last modification time of the corresponding metadata, then the file data of Video B stored in the disk cache data storage module is valid; if the last modification time of the file data of Video B stored in the disk cache data storage module is inconsistent with the last modification time of the corresponding metadata, then the file data of Video B stored in the disk cache data storage module is invalid.

[0252] If the file data of Video B stored in the disk cache data storage module is invalid, the disk cache file reading and writing module sends a read request to PAD 200 to obtain the file data of Video B from PAD 200. For example, the steps shown in S29 are executed.

[0253] If the file data of Video B stored in the disk cache data storage module is valid, the disk cache file reading and writing module checks whether the file segment of Video B is hit. For example, the steps shown in S210 are executed.

[0254] S29: The disk cache file reading and writing module requests PAD 200 to obtain the file data of Video B.

[0255] The disk cache file reading and writing module requests PAD 200 to obtain the file data of Video B, which is similar to obtaining the file data of Picture A from PAD 200, that is, the steps from S125 to S133 are similar, and will not be elaborated here.

[0256] S210: The disk cache file reading and writing module obtains the file segment of Video B.

[0257] It can be understood that video files are usually large files. In a possible case, only partial file data of Video B is cached in mobile phone 100. Therefore, every time a file segment of Video B is read, it is necessary to first determine whether the currently read file segment of Video B is stored in the disk cache data storage module, that is, it is necessary to judge whether the file segment of Video B is hit every time.

[0258] If the file segment of Video B read this time is hit, the file segment of Video B read this time is stored in the disk cache data storage module, and the disk cache file reading and writing module can directly read the file segment of Video B read this time from the disk cache data storage module.

[0259] If the file segment of Video B read this time is not hit, the file segment of Video B read this time is not stored in the disk cache data storage module, and the disk cache file reading and writing module can read the file segment of Video B read this time from PAD 200. After the disk cache file reading and writing module successfully reads the file segment of Video B read this time from PAD 200, it can also store the file segment of Video B read this time in the disk cache data storage module and update the index information of Video B at the same time.

[0260] For example, when the file segment of Video B is read for the first time, the index information of Video B is stored in the disk cache data storage module, such as Figure 19The initial index information shown in the figure. Among them, the assignment "5" on the left side of the first line represents the disk cache version number; the assignment "0" on the right side of the first line indicates that no data has been written to this file; the assignment "11534336" on the second line indicates that 11534336 bytes of data have been written to this file; the assignment "0" on the third line indicates that the size of the written file data corresponding to video B stored in the disk cache data storage module is 0; the assignment "(0, 1048576)" on the fourth line indicates that there is a file segment with a starting address of 0 and a file size of 1048576 bytes; the assignments on the fifth line, the sixth line... are similar to the assignment on the fourth line, and will not be elaborated here.

[0261] As Figure 19 shown, when the disk cache file read / write module reads the file segment of video B for the first time, the disk cache file read / write module determines the address information of the file data of video B read this time based on the read / write request as: a file segment with a starting address of 0 and a file size of 1048576 bytes, which is the same as the assignment on the fourth line in the initial index information, that is, the currently read file segment of video B hits. Therefore, the disk cache file read / write module can directly read the file segment of video B with a starting address of 0 and a file size of 1048576 bytes from the disk cache data storage module.

[0262] When the disk cache file read / write module reads the file segment of video B for the second time, the disk cache file read / write module determines the address information of the file data of video B read this time based on the read / write request as: a file segment with a starting address of 1048576 and a file size of 1048576 bytes, which is the same as the assignment on the fifth line in the initial index information, that is, the currently read file segment of video B hits. Therefore, the disk cache file read / write module can directly read the file segment of video B with a starting address of 1048576 and a file size of 1048576 bytes from the disk cache data storage module.

[0263] It can be understood that since video files are usually large, only part of the file was cached last time when caching video B. For example, only 5242880 bytes of the file were cached last time when caching video B. Therefore, when reading the file segment of video B with a starting address of 5242880 and a file size of 1048576 bytes, there is no such file segment in the disk cache data storage module. Reading the file segment of video B with a starting address of 5242880 and a file size of 1048576 bytes will result in a miss.

[0264] When the disk cache file read / write module reads the file segment of video B for the i-th time, the disk cache file read / write module determines the address information of the file data of video B read this time based on the read / write request as follows: the file segment with a starting address of 5242880 and a file size of 1048576 bytes is different from the assignment of any line in the initial index information, that is, the currently read file segment of video B misses. Therefore, the disk cache file read / write module cannot directly read the file segment of video B with a starting address of 5242880 and a file size of 1048576 bytes from the disk cache data storage module. The disk cache file read / write module needs to read the file segment of video B with a starting address of 5242880 and a file size of 1048576 bytes from PAD 200. Reading the file segment of video B with a starting address of 5242880 and a file size of 1048576 bytes from PAD 200 is similar to the steps from S125 to S133 in the Figure 13 illustrated embodiment, and will not be repeated here. It should be noted that after the disk cache file read / write module reads the file segment of video B with a starting address of 5242880 and a file size of 1048576 bytes from PAD 200, it will store the file segment of video B with a starting address of 5242880 and a file size of 1048576 bytes in the disk cache data storage module and update the index information of video B. Compared with the initial index information, the updated index information adds an assignment of "(5242880, 1048576)", indicating the starting address and file size of the file segment of video B read this time.

[0265] It can be understood that the cached part of the file was not continuous when video B was cached last time. Therefore, after the file segment of video B misses in the i-th read, when reading the file segment of video B again (for example, the (i + 2)-th time), it is possible that the file segment of video B is hit.

[0266] For example, when the disk cache file read / write module reads the file segment of video B for the (i + 2)-th time, the disk cache file read / write module determines the address information of the file data of video B read this time based on the read / write request as follows: the file segment with a starting address of 7340032 and a file size of 1048576 bytes is the same as the assignment of a line in the initial index information, that is, the currently read file segment of video B is hit. Therefore, the disk cache file read / write module can directly read the file segment of video B with a starting address of 7340032 and a file size of 1048576 bytes from the disk cache data storage module.

[0267] When the disk cache file read / write module fails to hit the file segment read from video B each time, it reads the file segment from PAD200. Correspondingly, the disk cache file read / write module updates the index information of video B. Therefore, for this read of video B, the updated index information is different from the initial index information, and the index information for reading the file segment from PAD 200 is added. As Figure 19 shown in the final index information.

[0268] S211. The disk cache file read / write module notifies the disk cache metadata storage module to update the metadata.

[0269] Among them, similar to the step S138 in the Figure 13 shown embodiment, when reading the file segment of video B each time, the third-line assignment of the metadata of video B will be updated. For example, as Figure 20 shown, when reading the file segment of video B for the first time, the third-line assignment is "1701412887", indicating that the access time for reading the file segment of picture A for the first time is "1701412887"; when reading the file segment of video B for the last time, the third-line assignment is updated to "1701412895", indicating that the access time for reading the file segment of picture A for the last time is "1701412895".

[0270] S212. The disk cache file read / write module returns the file data of video B to the global collection App.

[0271] It can be understood that the disk cache file read / write module can return the file data of video B to the global collection App through the disk cache upper limit management module, file management module, FUSE user-mode file system framework module, and Linux kernel module in sequence. Similar to the steps S146 to S150 in the Figure 13 shown embodiment, it will not be elaborated here.

[0272] S213. The global collection App displays video B.

[0273] It can be understood that, as shown in (c) in Figure 12 and (d) in Figure 12 , the user can also modify the document 203 stored in PAD 200 in the mobile phone 100. The following will illustrate how the mobile phone 100 modifies the document C stored in PAD 200 through the Figure 21 shown embodiment.

[0274] Figure 21 is a schematic flowchart of a file access method provided by an embodiment of the present application. As Figure 21 shown, the method includes:

[0275] S31. Display document C on mobile phone 100 through the global collection App.

[0276] Among them, the specific process of displaying document C stored in PAD 200 on mobile phone 100 through the global collection App is similar to the above Figure 13 and Figure 18 illustrated embodiments and will not be elaborated here.

[0277] S32. In response to the user's modification operation on document C, the global collection App modifies document C and sends a write request to the disk cache upper limit management module.

[0278] Among them, the write request may carry the file handle, start position, and file size of document C, and the write request may also carry the modification data for this modification of document C. The write request is used to request writing the relevant data of the modified document C this time.

[0279] It can be understood that the global collection App sending a write request to the disk cache upper limit management module may sequentially send the above write request to the disk cache upper limit management module through the Linux kernel module, the FUSE user-space file system framework module, and the file management module.

[0280] S33. The disk cache upper limit management module determines whether the remaining space in the disk cache data storage module is greater than a preset threshold.

[0281] If the remaining space in the disk cache data storage module is greater than the preset threshold, then execute S34, that is, send a write request to the disk cache file read / write module.

[0282] Among them, the preset threshold may be the maximum remaining space of the disk cache determined by the above disk cache upper limit management module's management rules for the disk cache upper limit, that is, based on the remaining space of the mobile phone disk to adjust the maximum remaining space of the disk cache.

[0283] S34. The disk cache file read / write module sends a write request to the disk cache data storage module.

[0284] S35. The disk cache data storage module stores the updated document C based on the write request.

[0285] S36. The disk cache data storage module updates the index information of document C.

[0286] It can be understood that the process of writing the updated data of document C can also be to write all the updated data into the disk cache data storage module in batches, and the data written each time can be called an updated file segment of document C. Each time an updated file segment of document C is written, the index information of document C will be modified.

[0287] Exemplarily, as Figure 22 shown, the initial index information of Document C is as Figure 22 shown in the initial index information. When the disk cache data storage module stores the updated Document C, it is equivalent to writing a segment of data into the disk cache data storage module. For example, as Figure 22 shown, the disk cache data storage module writes data with a starting address of 0 and a data size of 524288. Therefore, based on the written data, the index information of the updated Document C is as shown in the index information after the first write. The value in the third line is modified to "524288", indicating that a total of 524288 bytes of data have been written, and a new line of data is added, with the value "(0, 524288)", indicating that the starting address of the newly added data is 0 and the data size is 524288. It should be understood that when writing the updated file segment of Document C, the data on the right side of the first line in the index information changes from the initial "0" to "1", indicating that the current data is the written data.

[0288] When writing the updated file segment of Document C for the second time, the disk cache data storage module writes data with a starting address of 524288 and a data size of 1048576. Therefore, compared with the index information after the first write, the index information after the second write adds a line of data with the value "(524288, 1048576)", indicating that the starting address of the newly added data is 524288 and the data size is 1048576. The value in the fourth line of the index information after the second write becomes "1572864", indicating that a total of 524288 + 1048576 = 1572864 bytes of data have been written. Similarly, when writing the updated file segment of Document C for the second time, the value on the right side of the first line in the index information is assigned "1", indicating that the current data is the written data.

[0289] When writing the updated file segment of Document C for the third time, the disk cache data storage module writes data with a starting address of 1572864 and a data size of 524288. Therefore, compared with the index information after the second write, the index information after the third write adds a line of data with the value "(1572864, 524288)", indicating that the starting address of the newly added data is 1572864 and the data size is 524288. The value in the fourth line of the index information after the third write becomes "2097152", indicating that a total of 1572864 + 524288 = 2097152 bytes of data have been written. Similarly, when writing the updated file segment of Document C for the third time, the value on the right side of the first line in the index information is assigned "1", indicating that the current data is the written data.

[0290] S37. The disk cache data storage module returns an indication message indicating successful writing of the updated document C to the disk cache file reading / writing module.

[0291] S38. The disk cache file reading / writing module sends an update request to the disk cache metadata storage module.

[0292] S39. The disk cache metadata storage module updates the metadata information of document C based on the update request.

[0293] Exemplarily, the initial metadata of document C is as Figure 23 shown in the initial metadata. Each time data is written, the write time of the metadata is modified once.

[0294] S310. The disk cache metadata storage module returns an indication message indicating successful metadata update to the disk cache file reading / writing module.

[0295] S311. The disk cache file reading / writing module returns an indication message indicating successful file writing to the global collection App.

[0296] S312. The disk cache file reading / writing module determines whether the written data exceeds a preset threshold.

[0297] If the written data exceeds the preset threshold, then S313 to S318 are executed, that is, the written data is read from the disk cache data storage module and the above-written data, that is, the modified data of document C, is written to the PAD200.

[0298] Among them, the preset threshold can be the maximum remaining space of the disk cache determined by the above disk cache upper limit management module's management rule for the disk cache upper limit, that is, the maximum remaining space of the disk cache is adjusted based on the remaining space of the mobile phone disk.

[0299] S313. The disk cache file reading / writing module sends a first read request to the disk cache data storage module.

[0300] The first read request is used to read the current modified data of document C.

[0301] S314. The disk cache data storage module reads the first modified data in response to the first read request.

[0302] Among them, the first modified data refers to the current modified data of document C, that is, the data written to the disk cache data storage module.

[0303] S315. The disk cache data storage module updates the index information.

[0304] Among them, since the written data exceeds the preset threshold, it is necessary to retrieve the first modified data originally stored in the disk cache data storage module. Therefore, the data assignment on the right side of the first line changes from "1" to "0", indicating that the data has been read. And since the first modified data stored in the disk cache data storage module is retrieved, that is, the first modified data does not exist in the disk cache data storage module, the corresponding index information does not include the index of the written data, that is, the three lines of index information "(0, 524288)", "(524288, 1048576)" and "(1572864, 1048576)" are deleted.

[0305] S316. The disk cache data storage module sends the first modified data to the disk cache file read / write module.

[0306] S317. The disk cache file read / write module writes the first modified data to the PAD 200.

[0307] It can be understood that the specific process of the disk cache file read / write module writing the first modified data to the PAD 200 can be: the disk cache file read / write module sequentially sends the first modified data to the local file system module in the PAD 200 through the message transceiver module in the mobile phone 100, the message transceiver module in the PAD 200, and the service processing module in the PAD 200, so that the local file system module in the PAD 200 stores the first modified data. After storing the first modified data, the local file system module in the PAD 200 sequentially returns an indication message indicating successful writing of the modified data to the disk cache file read / write module through the service processing module in the PAD 200, the message transceiver module in the PAD 200, and the message transceiver module in the mobile phone 100.

[0308] S318. The disk cache file read / write module sends a message indicating that the writing is completed to the global favorite App.

[0309] When the user finishes modifying the document C, the user usually closes the document C. When the user closes the document C, the mobile phone 100 usually sends all the modified data of the user this time to the PAD 200 to achieve the effect of modifying the document in the PAD 200 through the mobile phone 100.

[0310] S319. In response to the fourth operation, the global favorite App sends a close instruction to the disk cache file read / write module.

[0311] Among them, the fourth operation may refer to the operation of closing Document C. For example, the fourth operation may be the operation of swiping up on the display interface of Document C to close Document C, or the operation of clicking the close control displayed on the display interface of Document C, or the operation of closing Document C through the voice assistant. The embodiments of the present application do not limit this.

[0312] It can be understood that the global favorite App sending a close instruction to the disk cache file reading and writing module may be sequentially sending the above-mentioned close request to the disk cache file reading and writing module through the Linux kernel module, the FUSE user-space file system framework module, and the file management module.

[0313] S320. In response to the close request, the disk cache file reading and writing module sends a second read request to the disk cache data storage module.

[0314] Among them, the second read request is used to read all the modified data of Document C.

[0315] S321. In response to the read request, the disk cache data storage module reads the second modified data.

[0316] Among them, the second modified data refers to all the modified data of Document C during the period from when the user opens Document C in the mobile phone 100 until closing Document C, that is, all the modified data of Document C written to the disk cache data storage module.

[0317] S322. The disk cache data storage module updates the index information.

[0318] Similar to S315, updating the index information is to delete the index information of the written data to obtain the final index information, as Figure 22 shown.

[0319] S323. The disk cache data storage module sends the second modified data to the disk cache file reading and writing module.

[0320] S324. The disk cache file reading and writing module writes the second modified data to the PAD 200.

[0321] It can be understood that the specific process of the disk cache file reading and writing module writing the second modified data to the PAD 200 may refer to: the disk cache file reading and writing module sequentially sends the second modified data to the local file system module in the PAD 200 through the message sending and receiving module in the mobile phone 100, the message sending and receiving module in the PAD 200, and the service processing module in the PAD 200, so that the local file system module in the PAD 200 stores the second modified data, and after storing the second modified data, the local file system module in the PAD 200 sequentially passes through the service processing module in the PAD 200, the message sending and receiving module in the PAD 200, and the message sending and receiving module in the mobile phone 100 to return an indication message indicating that the writing of the second modified data is successful to the disk cache file reading and writing module.

[0322] S325. The disk cache file reading and writing module sends an indication message indicating that the writing of the second modified data is successful to the global favorite App.

[0323] It can be understood that successfully writing the second modified data is equivalent to completing the task of closing Document C. Therefore, the indication message indicating that the writing of the second modified data is successful is also equivalent to the indication message indicating that the closing of Document C is completed.

[0324] The specific process of the disk cache file reading and writing module sending an indication message indicating that the writing of the second modified data is successful to the global favorite App may refer to: the disk cache file reading and writing module sequentially sends an indication message indicating that the writing of the second modified data is successful to the global favorite App through the file management module, the FUSE user-space file system framework module, and the Linux kernel module.

[0325] Since the storage space of the disk cache is limited, it is necessary to clean the cache space of the disk in a timely manner to meet the user's needs. Optionally, cleaning the cache space of the disk can be performed by the above disk cache cleaning module. Among them, cleaning the cache space of the disk can be achieved through Figure 24 the steps shown.

[0326] S41. Determine the storage space occupied by each file in the disk cache.

[0327] S42. Based on the ratio between the storage space occupied by each file and the upper limit of the cache space, determine the storage space to be deleted.

[0328] Deleting the storage space may refer to releasing the files in this storage space so that this storage space can store other files.

[0329] The ratio between the storage space occupied by each file and the upper limit of the cache space may refer to the ratio of the disk cache space occupied by all the files cached in the disk cache. This ratio can be a pre-set ratio, such as 75%.

[0330] S43. Sort each file in the order of access time from front to back.

[0331] S44. Delete the storage space occupied by files that have not been accessed within a preset duration.

[0332] The preset duration can be determined by the user according to experience, such as one week.

[0333] S44. Determine whether the remaining space in the disk cache is less than a preset threshold.

[0334] Among them, the preset threshold can be a value determined by the user according to experience. For example, the preset threshold can refer to the percentage of the space occupied by files in the disk cache (such as 75%).

[0335] If the remaining space in the disk cache is less than the preset threshold, execute S45, that is, release the files in the disk cache using a preset algorithm until the remaining space in the disk cache is greater than or equal to the preset threshold.

[0336] S45. Release the files in the disk cache using a preset algorithm until the remaining space in the disk cache is greater than or equal to the preset threshold.

[0337] Among them, the preset algorithm can refer to an algorithm that deletes files at the file granularity using the LRU algorithm according to the access time.

[0338] Figure 25 It is a schematic flowchart of a file access method provided by an embodiment of the present application. As Figure 25 shown, this method is applied to a first electronic device, and this method includes:

[0339] S101. In response to a first operation, determine whether a first file is cached in the first electronic device. The first file is a file stored in a second electronic device, and the first operation is an operation of reading the first file.

[0340] It can be understood that the first operation can be the above-mentioned operation of reading Picture A, or the operation of reading Video B, or the operation of reading Document C. The embodiment of the present application does not limit this.

[0341] Optionally, the first file includes a picture file, a video file, and a document file.

[0342] The first electronic device can refer to the above-mentioned mobile phone 100, and the second electronic device can refer to the above-mentioned PAD 200. The embodiment of the present application does not limit this.

[0343] S102. If the first file is cached in the first electronic device, read the first file from the cache module in the first electronic device.

[0344] The file access method provided by the embodiment of the present application is applied to a first electronic device. By responding to a first operation, it is determined whether a first file stored in a second electronic device is cached in a cache module of the first electronic device. If the first file is cached in the cache module of the first electronic device, the first file is directly read from the cache module of the first electronic device. Since there is a time period for data interaction between the first electronic device and the second electronic device, by using the file access method provided by the embodiment of the present application, the process of the first electronic device obtaining the first file from the second electronic device can be avoided, the time required to read the first file is reduced, and thus the lag situation caused by the long reading time is avoided, improving the user experience.

[0345] Figure 26 It is a schematic flow chart of a file access method provided by an embodiment of the present application. As Figure 26 shown, this method is applied to a first electronic device, and this method includes:

[0346] S201. Respond to the first operation to determine the first identification information of the first file.

[0347] S202. Based on the first identification information, search for a second file in the first electronic device. The identification information of the second file is the first identification information, and the index information of the second file matches the index information of the first file.

[0348] Among them, the matching of the index information of the first file and the index information of the second file includes: the index information of the first file completely matches the index information of the second file, and the index information of the first file partially matches the index information of the second file.

[0349] If the index information of the first file partially matches the index information of the second file, the first sub-file in the first file is cached in the first electronic device. Among them, the first sub-file is the partial file in the first file whose index information matches the index information of the second file. Reading the first file from the cache module of the first electronic device includes: reading the first sub-file from the first electronic device and reading the second sub-file from the second electronic device. The second sub-file is the sub-file in the first file other than the first sub-file.

[0350] In the file access method provided by the embodiment of the present application, when determining whether the index information of the first file matches the index information of the second file, if the index information of the first file partially matches the index information of the second file, the first sub-file that matches the index information of the first file is read from the first electronic device, and the second sub-file that matches the index information of the first file is read from the second electronic device, so that when the first file is partially cached in the first electronic device, the cached partial sub-files can be read. Compared with reading the first file entirely from the second electronic device, the time required to read the first file can be reduced, the possibility of jamming caused by a long fetch time can be reduced, and the user experience can be improved.

[0351] S203. If the second file exists in the first electronic device, the first file is cached in the first electronic device, and the first file is read from the first electronic device.

[0352] S204. If the first file is not cached in the first electronic device, the first file is obtained from the second electronic device.

[0353] S205. Cache the first file in the first electronic device.

[0354] In the file access method provided by the embodiment of the present application, in the case where the first file is not cached in the first electronic device, the first file is obtained from the second electronic device and cached in the cache module of the first electronic device. In this way, when the first file is read next time, the first file can be read from the cache module of the first electronic device, avoiding the process of the first electronic device obtaining the first file from the second electronic device again, reducing the time required to read the first file next time, and further avoiding the jamming situation caused by a long reading time, thus improving the user experience.

[0355] Optionally, the file access method provided by the embodiment of the present application further includes:

[0356] S206. In response to the second operation, modify the first file cached in the first electronic device, where the second operation is used to modify the first file.

[0357] Figure 27 is a schematic flowchart of a file access method provided by the embodiment of the present application. As Figure 27 shown, this method is applied to the first electronic device. The first electronic device includes a disk cache file reading and writing module and a disk cache data storage module. This method includes:

[0358] S301. In response to the first operation, the disk cache file reading and writing module determines whether the first file is cached in the disk cache data storage module.

[0359] Optionally, the above "the disk cache file reading and writing module determines whether the first file is cached in the disk cache data storage module" can be implemented through the following steps:

[0360] 1. The disk cache file reading and writing module determines the first identification information of the first file.

[0361] 2. The disk cache file reading and writing module searches in the disk cache data storage module based on the first identification information to determine whether the first file is cached in the disk cache data storage module.

[0362] The disk cache file reading and writing module searches in the disk cache data storage module based on the first identification information to determine whether the first file is cached in the disk cache data storage module, including: the disk cache file reading and writing module searches for a second file in the disk cache data storage module based on the first identification information, the identification information of the second file is the first identification information, and the index information of the second file matches the index information of the first file; if the second file exists in the disk cache data storage module, the second file is the first file.

[0363] Optionally, the index information of the first file and the index information of the second file match, including: the index information of the first file completely matches the index information of the second file, and, the index information of the first file partially matches the index information of the second file. If the index information of the first file partially matches the index information of the second file, the first sub-file in the first file is cached in the disk cache data storage module, where the first sub-file is the partial file in the first file whose index information matches the index information of the second file. The disk cache file reading and writing module reads the first file from the disk cache data storage module, including: the disk cache file reading and writing module reads the first sub-file from the disk cache data storage module; the method further includes: the disk cache file reading and writing module reads a second sub-file from the second electronic device, and the second sub-file is the sub-file in the first file other than the first sub-file.

[0364] S302. If the first file is cached in the disk cache data storage module, the disk cache file reading and writing module reads the first file from the disk cache data storage module.

[0365] S303. If the first file is not cached in the disk cache data storage module, the disk cache file reading and writing module obtains the first file from the second electronic device.

[0366] S304. The disk cache file reading and writing module caches the first file in the disk cache data storage module.

[0367] Optionally, the method further includes: in response to a second operation, the disk cache file reading and writing module modifies the first file in the disk cache data storage module, and the second operation is used to modify the first file.

[0368] Optionally, the disk cache file read / write module is further configured to determine whether the remaining space of the disk cache data storage module is less than a preset threshold during the process of modifying the first file of the disk cache data storage module, and send the modified first file to the second electronic device when the remaining space of the disk cache data storage module is less than the preset threshold.

[0369] Optionally, the first electronic device further includes a disk cache upper limit management module, which is configured to determine the maximum storage space of the disk cache data storage module based on the remaining memory space of the first electronic device.

[0370] It should be understood that although the steps in the flowcharts in the above embodiments are shown in sequence according to the arrows, these steps do not necessarily need to be executed in the order indicated by the arrows. Unless there is a clear description in this article, the execution of these steps has no strict order limit, and these steps can be executed in other orders. Moreover, at least some of the steps in the flowchart may include multiple sub-steps or multiple stages. These sub-steps or stages do not necessarily need to be executed at the same time, but can be executed at different times. The execution order of these sub-steps or stages does not necessarily need to be sequential, but can be executed alternately or in turn with at least a part of other steps or sub-steps or stages of other steps.

[0371] It can be understood that in order to implement the above functions, the electronic device includes corresponding hardware and / or software modules for executing each function. Combining the algorithm steps of each example described in the embodiments disclosed in this article, the present application can be implemented in the form of hardware or a combination of hardware and computer software. Whether a certain function is executed in the way of hardware or computer software driving hardware depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application in combination with the embodiments, but such implementation should not be considered to exceed the scope of the present application.

[0372] The embodiments of the present application can divide the electronic device into function modules according to the above method examples. For example, each function module can be divided corresponding to each function, or two or more functions can be integrated into one module. It should be noted that the division of modules in the embodiments of the present application is illustrative, only a logical function division, and there can be other division methods in actual implementation. It should be noted that the names of the modules in the embodiments of the present application are illustrative, and the names of the modules are not limited in actual implementation.

[0373] Figure 28 It is a schematic structural diagram of a file access device provided by an embodiment of the present application.

[0374] It should be understood that the file access device 600 can execute Figures 13 to 27 the file access method shown; the file access device 600 includes: an acquisition unit 610 and a processing unit 620.

[0375] The processing unit 620 is configured to determine, in response to a first operation, whether a first file is cached in the first electronic device, where the first file is a file stored in a second electronic device, and the first operation is an operation of reading the first file;

[0376] The processing unit 620 is configured to, if the first file is cached in the first electronic device, read the first file from the first electronic device.

[0377] In one embodiment, the processing unit 620 is configured to determine first identification information of the first file; search in the first electronic device based on the first identification information to determine whether the first file is cached in the first electronic device.

[0378] In one embodiment, the processing unit 620 is configured to search for a second file in the first electronic device based on the first identification information, where the identification information of the second file is the first identification information and the index information of the second file matches the index information of the first file; if the second file exists in the first electronic device, the first file is cached in the first electronic device.

[0379] In one embodiment, the processing unit 620 is further configured to, if the first file is not cached in the first electronic device, obtain the first file from the second electronic device; cache the first file in the first electronic device.

[0380] In one embodiment, the matching of the index information of the first file and the index information of the second file includes: the index information of the first file completely matches the index information of the second file, and the index information of the first file partially matches the index information of the second file. The processing unit 620 is configured to, if the index information of the first file partially matches the index information of the second file, a first sub-file in the first file is cached in the first electronic device, where the first sub-file is a partial file in the first file whose index information matches the index information of the second file, and read the first sub-file from the cache module of the first electronic device; the processing unit 620 is further configured to read a second sub-file from the second electronic device, where the second sub-file is a sub-file in the first file other than the first sub-file.

[0381] In one embodiment, the processing unit 620 is further configured to modify the first file cached in the first electronic device in response to a second operation for modifying the first file.

[0382] In one embodiment, the first file includes a picture file, a video file, and a document file.

[0383] The file access device provided in this embodiment is used to execute the file access method of the above embodiment. The technical principles and technical effects are similar and will not be elaborated here.

[0384] It should be noted that the above file access device 600 is embodied in the form of a functional unit. The term "unit" here can be implemented in the form of software and / or hardware, and no specific limitation is made thereto.

[0385] For example, the "unit" can be a software program, a hardware circuit, or a combination of the two that implements the above functions. The hardware circuit may include an application specific integrated circuit (ASIC), an electronic circuit, a processor (such as a shared processor, a dedicated processor, or a group of processors, etc.) for executing one or more software or firmware programs, a memory, a merged logic circuit, and / or other suitable components that support the described functions.

[0386] Therefore, the units of the examples described in the embodiments of the present application can be implemented by electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are executed in a hardware or software manner depends on the specific application and design constraints of the technical solution. A person skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of the present application.

[0387] Figure 29 The structural schematic diagram of an electronic device provided by the present application is shown. Figure 29 The dashed line in indicates that the unit or the module is optional. The electronic device 700 can be used to implement the file access method described in the above method embodiment.

[0388] The electronic device 700 includes one or more processors 701, and the one or more processors 701 can support the electronic device 700 to implement the file access method in the method embodiments. The processor 701 can be a general-purpose processor or a dedicated processor. For example, the processor 701 can be a central processing unit (CPU), a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA), or other programmable logic devices, such as discrete gates, transistor logic devices, or discrete hardware components.

[0389] The processor 701 can be used to control the electronic device 700, execute software programs, and process the data of software programs. The electronic device 700 can also include a communication unit 705 for implementing signal input (reception) and output (transmission).

[0390] For example, the electronic device 700 can be a chip, and the communication unit 705 can be the input and / or output circuit of the chip, or the communication unit 705 can be the communication interface of the chip, and the chip can be a component of a terminal device or other electronic devices.

[0391] For another example, the electronic device 700 can be a terminal device, and the communication unit 705 can be the transceiver of the terminal device, or the communication unit 705 can be the transceiver circuit of the terminal device.

[0392] The electronic device 700 may include one or more memories 702, on which there is a program 704. The program 704 can be run by the processor 701 to generate instructions 703, so that the processor 701 executes the impedance matching method described in the above method embodiments according to the instructions 703.

[0393] Optionally, data can also be stored in the memory 702. Optionally, the processor 701 can also read the data stored in the memory 702. The data can be stored at the same storage address as the program 704, or the data can be stored at a different storage address from the program 704.

[0394] The processor 701 and the memory 702 can be set separately or integrated together; for example, integrated on a system on chip (SOC) of a terminal device.

[0395] Exemplarily, the memory 702 may be used to store the relevant program 704 of the file access method provided in the embodiments of the present application. The processor 701 may be used to call the relevant program 704 of the file access method stored in the memory 702 when performing file access, and execute the file access method of the embodiments of the present application, including: in response to a first operation, determining whether a first file is cached in a first electronic device, the first file being a file stored in a second electronic device, and the first operation being an operation of reading the first file; if the first file is cached in the first electronic device, reading the first file from the first electronic device.

[0396] The present application also provides a computer program product, which implements the file access method described in any method embodiment of the present application when executed by the processor 701.

[0397] The computer program product may be stored in the memory 702, for example, it is the program 704. The program 704 is finally converted into an executable target file that can be executed by the processor 701 after processes such as preprocessing, compilation, assembly, and linking.

[0398] The present application also provides a computer-readable storage medium, on which a computer program is stored. The computer program implements the file access method described in any method embodiment of the present application when executed by a computer. The computer program may be a high-level language program or an executable target program.

[0399] The computer-readable storage medium is, for example, the memory 702. The memory 702 may be a volatile memory or a non-volatile memory, or the memory 702 may include both a volatile memory and a non-volatile memory. Among them, the non-volatile memory may be a read-only memory (ROM), a programmable ROM (PROM), an erasable programmable ROM (EPROM), an electrically erasable programmable ROM (EEPROM), or a flash memory. The volatile memory may be a random access memory (RAM), which is used as an external cache. By way of example but not limitation, many forms of RAM are available, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDR SDRAM), enhanced SDRAM (ESDRAM), synchlink DRAM (SLDRAM), and direct rambus RAM (DR RAM).

[0400] In this application, "at least one" means one or more, and "a plurality" means two or more. "At least one of the following" or its similar expressions refer to any combination of these items, including any combination of single items or plural items. For example, at least one of a, b, or c may represent: a, b, c, a - b, a - c, b - c, or a - b - c, where a, b, and c may be single or multiple.

[0401] It should be understood that in various embodiments of this application, the sequence numbers of the above processes do not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation to the implementation process of the embodiments of this application.

[0402] Those of ordinary skill in the art can realize that the units and algorithm steps of the examples described in combination with the embodiments disclosed herein can be implemented by electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are executed in a hardware or software manner depends on the specific application and design constraints of the technical solution. Professional technicians can use different methods for each specific application to implement the described functions, but such implementation should not be considered to exceed the scope of this application.

[0403] Those skilled in the art can clearly understand that for the convenience and conciseness of description, the specific working processes of the systems, devices, and units described above can refer to the corresponding processes in the foregoing method embodiments and will not be elaborated herein.

[0404] 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 example, the division of the units is only a logical function division, and there may be other division methods in actual implementation; for example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the displayed or discussed couplings or direct couplings or communication connections to each other can be through some interfaces, and the indirect couplings or communication connections of the devices or units can be in electrical, mechanical, or other forms.

[0405] The units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or may be distributed to multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0406] In addition, the functional units in each embodiment of this application can be integrated into one processing unit, or each unit can exist physically alone, or two or more units can be integrated into one unit.

[0407] As mentioned above, the above is only the specific implementation manner of this application, but the protection scope of this application is not limited thereto. Any person skilled in the art can easily think of changes or substitutions within the technical scope disclosed in this application, and all should be covered by the protection scope of this application. Therefore, the protection scope of this application should be subject to the protection scope of the claims.

Claims

1. A file access method, characterized in that, The method is applied to a first electronic device, and the method includes: In response to a first operation, determining whether a first file is cached in the first electronic device, where the first file is a file stored in a second electronic device, and the first operation is an operation of reading the first file; If the first file is cached in the first electronic device, reading the first file from the first electronic device.

2. The method according to claim 1, characterized in that The determining whether the first file is cached in the first electronic device includes: Determining first identification information of the first file; Based on the first identification information, searching in the first electronic device to determine whether the first file is cached in the first electronic device.

3. The method according to claim 2, wherein The searching in the first electronic device based on the first identification information to determine whether the first file is cached in the first electronic device includes: Based on the first identification information, searching for a second file in the first electronic device, where the identification information of the second file is the first identification information, and the index information of the second file matches the index information of the first file; If the second file exists in the first electronic device, the second file is the first file.

4. The method according to any one of claims 1 to 3, characterized in that, The method further includes: If the first file is not cached in the first electronic device, obtaining the first file from the second electronic device; Caching the first file in the first electronic device.

5. The method according to claim 3, wherein The matching of the index information of the first file and the index information of the second file includes: the index information of the first file completely matches the index information of the second file, and the index information of the first file partially matches the index information of the second file. If the index information of the first file partially matches the index information of the second file, a first sub-file in the first file is cached in the first electronic device, where the first sub-file is a partial file in the first file whose index information matches the index information of the second file. The reading of the first file from the cache module of the first electronic device includes: Reading the first sub-file from the first electronic device; The method further includes: Reading a second sub-file from the second electronic device, where the second sub-file is a sub-file in the first file other than the first sub-file.

6. The method according to any one of claims 1 to 5, characterized in that, The method further includes: In response to a second operation, modifying the first file in the first electronic device, where the second operation is used to modify the first file.

7. The method according to any one of claims 1 to 6, characterized in that, The first electronic device includes a disk cache file read / write module and a disk cache data storage module. The determining, in response to the first operation, whether the first file is cached in the disk cache data storage module includes: In response to the first operation, the disk cache file read / write module determines whether the first file is cached in the disk cache data storage module; The reading of the first file from the first electronic device if the first file is cached in the first electronic device includes: If the first file is cached in the disk cache data storage module, the disk cache file read / write module reads the first file from the disk cache data storage module.

8. The method according to claim 7, wherein The disk cache file reading and writing module determines whether the first file is cached in the disk cache data storage module, including: The disk cache file reading and writing module determines the first identification information of the first file; The disk cache file reading and writing module searches in the disk cache data storage module based on the first identification information to determine whether the first file is cached in the disk cache data storage module.

9. The method according to claim 8, wherein The disk cache file reading and writing module searches in the disk cache data storage module based on the first identification information to determine whether the first file is cached in the disk cache data storage module, including: The disk cache file reading and writing module searches for a second file in the disk cache data storage module based on the first identification information, where the identification information of the second file is the first identification information, and the index information of the second file matches the index information of the first file; If the second file exists in the disk cache data storage module, the second file is the first file.

10. The method according to any one of claims 7 to 9, characterized in that The method further includes: If the first file is not cached in the disk cache data storage module, the disk cache file reading and writing module obtains the first file from the second electronic device; The disk cache file reading and writing module caches the first file in the disk cache data storage module.

11. The method according to claim 3, wherein The first electronic device includes a disk cache data storage module and a disk cache file reading and writing module. The index information of the first file and the index information of the second file match, including: the index information of the first file completely matches the index information of the second file, and the index information of the first file partially matches the index information of the second file. If the index information of the first file partially matches the index information of the second file, the first sub-file in the first file is cached in the disk cache data storage module, where the first sub-file is the partial file in the first file whose index information matches the index information of the second file. The disk cache file reading and writing module reads the first file from the disk cache data storage module, including: The disk cache file reading and writing module reads the first sub-file from the disk cache data storage module; The method further includes: The disk cache file reading and writing module reads a second sub-file from the second electronic device, where the second sub-file is the sub-file in the first file other than the first sub-file.

12. The method according to any one of claims 7 to 11, characterized in that The method further includes: In response to a second operation, the disk cache file reading and writing module modifies the first file in the disk cache data storage module, and the second operation is used to modify the first file.

13. The method according to claim 12, wherein The disk cache file reading and writing module is further configured to determine whether the remaining space in the disk cache data storage module is less than a preset threshold during the process of modifying the first file in the disk cache data storage module, and if the remaining space in the disk cache data storage module is less than the preset threshold, send the modified first file to the second electronic device.

14. The method according to any one of claims 7 to 13, characterized in that The first electronic device further includes a disk cache upper limit management module, and the disk cache upper limit management module is configured to determine the maximum storage space of the disk cache data storage module based on the remaining memory space of the first electronic device.

15. The method according to any one of claims 1 to 14, characterized in that, The first file includes a picture file, a video file, and a document file.

16. An electronic device, characterized in that, The electronic device includes a module for performing the method according to any one of claims 1 to 15.

17. An electronic device, characterized in that, Comprising: One or more processors; A memory; And one or more computer programs, wherein the one or more computer programs are stored on the memory, and when the computer programs are executed by the one or more processors, the electronic device is caused to perform the method according to any one of claims 1 to 15.

18. A chip system, characterized in that, The chip system includes a processor for calling and running a computer program from a memory, so that an electronic device installed with the chip system performs the method according to any one of claims 1 to 15.

19. A computer-readable storage medium, comprising a computer program, characterized in that, When the computer program runs on the electronic device, the electronic device is caused to perform the method according to any one of claims 1 to 15.

Citation Information

Patent Citations

  • File reading method and system

    CN106446097A

  • Data processing method and system

    CN107454154A

  • A method of accessing data across devices and a first electronic device

    CN109388620A

  • Data transmission method for mobile storage device

    CN113242321A

  • File sharing method and electronic equipment

    CN114328423A