CN113849753A - Dynamic picture caching method, device, equipment and storage medium - Google Patents

Dynamic picture caching method, device, equipment and storage medium Download PDF

Info

Publication number
CN113849753A
CN113849753A CN202111137730.2A CN202111137730A CN113849753A CN 113849753 A CN113849753 A CN 113849753A CN 202111137730 A CN202111137730 A CN 202111137730A CN 113849753 A CN113849753 A CN 113849753A
Authority
CN
China
Prior art keywords
target picture
picture
target
request
acquisition request
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202111137730.2A
Other languages
Chinese (zh)
Inventor
方科
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Ping An International Smart City Technology Co Ltd
Original Assignee
Ping An International Smart City Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Ping An International Smart City Technology Co Ltd filed Critical Ping An International Smart City Technology Co Ltd
Priority to CN202111137730.2A priority Critical patent/CN113849753A/en
Publication of CN113849753A publication Critical patent/CN113849753A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/95Retrieval from the web
    • G06F16/957Browsing optimisation, e.g. caching or content distillation
    • G06F16/9574Browsing optimisation, e.g. caching or content distillation of access to content, e.g. by caching
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/95Retrieval from the web
    • G06F16/958Organisation or management of web site content, e.g. publishing, maintaining pages or automatic linking
    • G06F16/972Access to data in other repository systems, e.g. legacy data or dynamic Web page generation

Landscapes

  • Engineering & Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Transfer Between Computers (AREA)

Abstract

The invention relates to the field of artificial intelligence and discloses a dynamic picture caching method, a dynamic picture caching device, dynamic picture caching equipment and a dynamic picture caching storage medium. The method comprises the following steps: receiving a target picture acquisition request sent by a user through a resource request interface; calculating a hash value of the target picture acquisition request based on a hash algorithm; determining the file name of the target picture according to the hash value; judging whether a corresponding target picture exists in a preset cache folder of the picture cache according to the file name; if the target picture does not exist in the preset cache folder, sending a target picture obtaining request to the server, obtaining a target picture corresponding to the target picture obtaining request, storing the target picture in the preset cache folder, generating a target file path corresponding to the storage position of the target picture and sending the target file path to the client; and if so, acquiring a target file path for storing the target picture from the hash value and sending the target file path to the client. The invention can solve the problems that the picture is reloaded when the page is refreshed every time and the loading efficiency is low.

Description

Dynamic picture caching method, device, equipment and storage medium
Technical Field
The present invention relates to the field of artificial intelligence technology, and in particular, to a dynamic picture caching method, apparatus, device, and storage medium.
Background
Electron is a framework for building desktop applications using JavaScript, HTML, and CSS. By utilizing the framework, the Web front-end personnel can quickly construct desktop programs by using the existing Web framework, UI component libraries and the like, and the framework has the advantage of cross-platform, can run in desktop operating systems such as Windows, Mac, Linux and the like, improves the efficiency and reuses rich UI components of the Web end.
At present, a plurality of trends similar to friend circles are displayed on dynamic pages of work circles of a plurality of products, and each dynamic has a plurality of high-definition pictures, so that a front-end page needs to obtain a large number of large pictures from a rear end for displaying, because of the limitation of the number of requests of a Chrome kernel, the maximum concurrency number of requests of the same domain name is limited to 6, when the number of the requests of the same domain name is larger than 6 due to the large picture resource of the rear end and long time spent on the requests, subsequent requests can be blocked, the interface is blocked, and the picture resource can be requested again when the page is refreshed each time, and the normal use of a user is seriously influenced. In a general scheme, a background is required to separate a domain name of a picture resource from domain names of other interfaces, so that a large picture can be requested without blocking other requests, but the scheme has the problems that the picture needs to be reloaded by refreshing a page every time and the loading efficiency is low, and the user experience is influenced.
Disclosure of Invention
The invention provides a dynamic picture caching method, a dynamic picture caching device and a dynamic picture caching storage medium, which can solve the problems that a picture is reloaded when a page is refreshed every time and the loading efficiency is low.
In order to solve the technical problems, the invention adopts a technical scheme that: a dynamic picture caching method is provided, which is applied to a picture cache running on a client, wherein the picture cache is provided with a resource request interface and a service request interface, and the method comprises the following steps:
receiving a target picture acquisition request sent by a user through the resource request interface;
calculating a hash value of the target picture acquisition request based on a hash algorithm;
determining the file name of the target picture according to the hash value;
judging whether a corresponding target picture exists in a preset cache folder of the picture cache according to the file name;
if the target picture corresponding to the file name does not exist in the preset cache folder, sending the target picture obtaining request to a server side, obtaining the target picture corresponding to the target picture obtaining request, storing the target picture in the preset cache folder, generating a target file path corresponding to the storage position of the target picture and sending the target file path to the client side;
and if the target picture corresponding to the file name exists in the preset cache folder, acquiring a target file path for storing the target picture from the hash value and sending the target file path to the client.
According to an embodiment of the present invention, if there is no target picture corresponding to the file name in the preset cache folder, the step of sending the target picture acquisition request to a server, acquiring the target picture corresponding to the target picture acquisition request, storing the target picture in the preset cache folder, generating a target file path corresponding to a storage location of the target picture, and sending the target file path to the client further includes:
when the target picture acquisition request is sent to the server, storing the target picture acquisition request in a preset resource downloading list;
when a new picture acquisition request is sent to the server again, judging whether the new picture acquisition request is already stored in the preset resource downloading list or not;
if so, after the target picture acquisition request is processed, acquiring a target picture corresponding to the target picture acquisition request, storing the target picture in the preset cache folder, generating a target file path corresponding to the storage position of the target picture, and sending the target file path to the client;
and if not, sending a new picture acquisition request to the server side and caching the new picture acquisition request into the preset resource downloading list.
According to an embodiment of the present invention, the step of waiting for the target picture acquisition request to be processed further includes:
and recording waiting time in the process of waiting for the completion of the processing of the target picture acquisition request, and if the waiting time exceeds a preset time threshold, re-sending the target picture acquisition request to the server side.
According to an embodiment of the present invention, after the step of resending the target picture obtaining request to the server, the method further includes:
and recording the sending times, and if the sending times exceed a preset time threshold, stopping sending the target picture acquisition request to the server and feeding back downloading failure information to the client.
According to an embodiment of the present invention, after receiving, through the resource request interface, a target picture obtaining request sent by a user, the method further includes:
judging whether the target picture acquisition request is stored in a preset resource calling list or not, wherein the preset resource calling list stores the picture acquisition request in process;
if so, after waiting for acquiring a target picture corresponding to the target picture acquisition request, sending the target picture to the client;
if not, caching the target picture acquisition request into the preset resource calling list, and processing the target picture acquisition request to acquire a corresponding target picture.
According to an embodiment of the invention, the method further comprises:
and scanning the preset cache folder regularly and carrying out corresponding cleaning operation on the target picture stored in the preset cache folder according to a scanning result and a preset strategy.
According to an embodiment of the invention, the method further comprises:
receiving a service request sent by the user through the service request interface;
forwarding the service request to a server side to process the service request;
and acquiring the processing result of the server and sending the processing result to the client.
In order to solve the technical problem, the invention adopts another technical scheme that: the method comprises the following steps of providing a picture buffer which is arranged on a client, wherein the picture buffer is provided with a resource request interface and a service request interface, and the picture buffer comprises:
the receiving module is used for receiving a target picture acquisition request sent by a user through the resource request interface;
the calculation module is used for calculating a hash value of the target picture acquisition request based on a hash algorithm;
the determining module is used for determining the file name of the target picture according to the hash value;
the judging module is used for judging whether a corresponding target picture exists in a preset cache folder of the picture cache according to the file name;
a first obtaining module, configured to send a target picture obtaining request to a server if a target picture corresponding to the file name does not exist in the preset cache folder, obtain the target picture corresponding to the target picture obtaining request, store the target picture in the preset cache folder, generate a target file path corresponding to a storage location of the target picture, and send the target file path to the client;
and the second obtaining module is used for obtaining a target file path for storing the target picture from the hash value and sending the target file path to the client if the target picture corresponding to the file name exists in the preset cache folder.
In order to solve the technical problems, the invention adopts another technical scheme that: there is provided a computer device comprising: the dynamic picture caching method comprises a memory, a processor and a computer program which is stored on the memory and can run on the processor, wherein the processor realizes the dynamic picture caching method when executing the computer program.
In order to solve the technical problems, the invention adopts another technical scheme that: there is provided a computer storage medium having stored thereon a computer program which, when executed by a processor, implements the above-described moving picture caching method.
The invention has the beneficial effects that: the resource request interface and the service request interface are separated at the client, so that the picture resource is ensured to be obtained from the resource request interface without blocking other service requests, and the overall request processing efficiency is improved; the downloaded picture resources are cached by deploying the picture buffer at the client, and the target picture is obtained by utilizing the file path, so that the picture calling efficiency is improved, and the problem of repeated downloading requests for refreshing the page is solved.
Drawings
FIG. 1 is a flowchart illustrating a method for caching a moving picture according to a first embodiment of the present invention;
FIG. 2 is a schematic diagram of a network architecture according to a first embodiment of the present invention;
fig. 3 is a flowchart illustrating step S105 in the method for caching a moving picture according to the embodiment of the present invention;
FIG. 4 is a flowchart illustrating a method for caching a moving picture according to a second embodiment of the present invention;
FIG. 5 is a flowchart illustrating a method for caching a moving picture according to a third embodiment of the present invention;
FIG. 6 is a diagram illustrating a structure of a picture buffer according to an embodiment of the present invention;
FIG. 7 is a schematic structural diagram of a computer device according to an embodiment of the present invention;
fig. 8 is a schematic structural diagram of a computer storage medium according to an embodiment of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
The terms "first", "second" and "third" in the present invention are used for descriptive purposes only and are not to be construed as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined as "first," "second," or "third" may explicitly or implicitly include at least one of the feature. In the description of the present invention, "a plurality" means at least two, e.g., two, three, etc., unless specifically limited otherwise. All directional indicators (such as up, down, left, right, front, and rear … …) in the embodiments of the present invention are only used to explain the relative positional relationship between the components, the movement, and the like in a specific posture (as shown in the drawings), and if the specific posture is changed, the directional indicator is changed accordingly. Furthermore, the terms "include" and "have," as well as any variations thereof, are intended to cover non-exclusive inclusions. For example, a process, method, system, article, or apparatus that comprises a list of steps or elements is not limited to only those steps or elements listed, but may alternatively include other steps or elements not listed, or inherent to such process, method, article, or apparatus.
Reference herein to "an embodiment" means that a particular feature, structure, or characteristic described in connection with the embodiment can be included in at least one embodiment of the invention. The appearances of the phrase in various places in the specification are not necessarily all referring to the same embodiment, nor are separate or alternative embodiments mutually exclusive of other embodiments. It is explicitly and implicitly understood by one skilled in the art that the embodiments described herein can be combined with other embodiments.
The embodiment of the application can acquire and process related data based on an artificial intelligence technology. Among them, Artificial Intelligence (AI) is a theory, method, technique and application system that simulates, extends and expands human Intelligence using a digital computer or a machine controlled by a digital computer, senses the environment, acquires knowledge and uses the knowledge to obtain the best result.
The artificial intelligence infrastructure generally includes technologies such as sensors, dedicated artificial intelligence chips, cloud computing, distributed storage, big data processing technologies, operation/interaction systems, mechatronics, and the like. The artificial intelligence software technology mainly comprises a computer vision technology, a robot technology, a biological recognition technology, a voice processing technology, a natural language processing technology, machine learning/deep learning and the like.
Fig. 1 is a flowchart illustrating a method for caching a moving picture according to a first embodiment of the present invention. It should be noted that the method of the present invention is not limited to the flow sequence shown in fig. 1 if the results are substantially the same. The method of the present invention is applied to a picture buffer running on a client, as shown in fig. 2, a client 21 interacts with a server 23, the client 21 is provided with the picture buffer 210, the picture buffer 210 is provided with a resource request interface 211 and a service request interface 212, and as shown in fig. 1, for the resource request interface 211, the method includes the steps of:
step S101: and receiving a target picture acquisition request sent by a user through a resource request interface.
In step S101, the target picture obtaining request is in a URL format, i.e., a Uniform Resource Locator (URL), where the URL is a concise representation of a location and an access method of a Resource available from the internet and is an address of a standard Resource on the internet. Each file on the internet has a unique URL. The picture buffer of this embodiment is deployed on a client, which may be an Electron and the picture buffer is Net Core. Electron is a framework for building desktop applications using JavaScript, HTML, and CSS. The framework can enable Web front-end personnel to quickly construct desktop programs by using the existing Web framework, UI component libraries and the like, has the advantage of cross-platform, can run in desktop operating systems such as Windows, Mac, Linux and the like, improves the efficiency and reuses rich UI components at a Web end. Net Core is an open-source universal development framework that supports cross-platform, i.e., development and deployment on windows, MacOS, Linux, etc., and can be used in hardware devices, cloud services, and embedded/internet of things solutions.
Due to the fact that the concurrency number of the Chrome kernel of the Electron is limited, other requests are blocked, and jamming occurs, the conventional method that the picture resource server and the service interface server receive corresponding requests separately at the back end cannot completely solve the problem of user experience of the client. According to the embodiment, the image acquisition request and the service request are separated at the client, so that the situation that other service requests are blocked due to the fact that the image resources need to be downloaded from the rear end is prevented, and user experience is improved.
In the embodiment, Net Core hybrid programming is adopted, Net Core is used as a middle layer, request proxy is carried out on Electron, the Electron and the Net Core share file resources in a PC computer, all picture resources downloaded by the Net Core can be directly obtained from the Electron through a file path. The Net Core runs on the client instead of the backend, and is distributed on the backend with a traditional proxy server.
Step S102: and calculating the hash value of the target picture acquisition request based on a hash algorithm.
In step S102, the hash algorithm maps a binary value of an arbitrary length to a smaller binary value of a fixed length, wherein the smaller binary value is a hash value. The hash algorithm is a one-way algorithm, the target picture acquisition request URL is converted into an output with a fixed length, and different target picture acquisition request URLs have different hash values. And mapping the file name of the target picture corresponding to the target picture acquisition request through the hash value.
Step S103: and determining the file name of the target picture according to the hash value.
In step S103, the hash value is mapped to a file name of a target picture in a preset cache folder of the picture buffer, where the preset cache folder is used for storing all pictures downloaded by Net Core from the background, so as to facilitate picture management and call. And mapping different file names of the target pictures correspondingly by using different hash values. Specifically, the hash value is mapped to a file name of the target picture in the preset cache folder through a file path. The file path is a location where the file is stored, for example: the target picture acquisition request URL is: the method comprises the following steps of http:// image.xx.cn/work/20210826/logo.jpg, and obtaining a corresponding hash value according to a hash algorithm: 59a24db8915f6998f55514 aeddeeec 949049c7b39, if the cached file directory is d: \ imageCache, the file path for downloading the saved target picture is: d \ imageCache \59a 24db8915f6998f55514aedeec 949049c7b39.JPG, the file path represents a picture file of JPG format "59 a24db8915f6998f55514 aedeec 949049c7b 39", stored in the folder "imageCache" of "d" disk, then the file name of the target picture is: 59a 24db8915f6998f55514aeddecec949049c7b 39. jpg. If a target picture with the file name of "59 a 24db8915f6998f55514aedeec 949049c7b39. jpg" is to be acquired, the picture file needs to be found according to the file path first-level, and corresponding operation can be carried out.
Step S104: and judging whether a corresponding target picture exists in a preset cache folder of the picture cache according to the file name.
In step S104, the target picture is the target picture corresponding to the target picture obtaining request, because in step S103, the position of the target picture to be obtained can be determined according to the file path, but it cannot be determined whether the target picture corresponding to the file name is stored in the cache folder, and only the file name of the target picture to be obtained in advance can be determined according to the hash value, and therefore, the determination of whether the corresponding target picture exists in the preset cache folder of the picture buffer according to the file name is continuously performed. In step S104, if the target picture corresponding to the file name does not exist in the preset cache folder, step S105 is executed, and if the target picture corresponding to the file name exists in the preset cache folder, step S106 is executed.
Step S105: if the target picture corresponding to the file name does not exist in the preset cache folder, sending a target picture obtaining request to the server side, obtaining the target picture corresponding to the target picture obtaining request, storing the target picture in the preset cache folder, generating a target file path corresponding to the storage position of the target picture and sending the target file path to the client side.
In step S105, the server may be an independent server, or may be a cloud server that provides basic cloud computing services such as a cloud service, a cloud database, cloud computing, a cloud function, cloud storage, a Network service, cloud communication, a middleware service, a domain name service, a security service, a Content Delivery Network (CDN), and a big data and artificial intelligence platform. In this embodiment, a hash value is calculated according to a storage location of a target picture based on a hash algorithm, the hash value is mapped into a target file path for storing the target picture, the target file path is sent to a client, and the client acquires a corresponding target picture according to the target file path. When the picture acquisition request URL for acquiring the target picture which is repeatedly refreshed or sent again by the user is acquired, the downloaded target picture is cached by deploying the picture buffer at the client, the target picture is acquired by utilizing the target file path, the picture calling efficiency is improved, and the problem of repeated downloading requests for refreshing the page is solved.
Further, in this embodiment, the target picture is stored in the preset cache folder, the preset cache folder is periodically scanned, and the corresponding cleaning operation is performed on the target picture stored in the preset cache folder according to the scanning result and the preset policy. Specifically, the preset policy includes: 1. acquiring the last access time of the target picture according to the scanning result, determining whether the target picture is an overdue cache file or not according to the last access time, and performing corresponding cleaning operation when the target picture is determined to be the overdue cache file; 2. and calculating the total capacity of all target pictures according to the scanning result, and if the total capacity exceeds a preset capacity threshold, removing the target pictures which are not accessed and the overdue cache files. By means of the method, the reading speed of the frequently accessed pictures can not be influenced, occupied space can be limited, and therefore picture obtaining efficiency is improved.
Further, referring to fig. 3, step S105 further includes the following steps:
step S301: and when the target picture acquisition request is sent to the server, storing the target picture acquisition request in a preset resource downloading list.
In this embodiment, the Net Core is provided with a preset resource download list, and the preset resource download list stores the picture acquisition request being processed.
Step S302: and when a new picture acquisition request is sent to the server again, judging whether the new picture acquisition request is already stored in the preset resource downloading list.
In step S302, comparing whether the new picture obtaining request is the same as the picture obtaining request in the preset resource downloading list, if so, indicating that the new picture obtaining request already exists in the preset resource downloading list and the new picture obtaining request is being processed, executing step S303, and refusing to add the new picture obtaining request into the preset resource downloading list so as to avoid the problem of prolonging the picture loading time due to repeated requests; if not, it indicates that there is no new picture acquisition request in the preset resource download list, then step S304 is executed to add the new picture acquisition request into the preset resource download list, and wait for picture loading.
Step S303: if so, after the target picture acquisition request is processed, acquiring a target picture corresponding to the target picture acquisition request, storing the target picture in a preset cache folder, generating a target file path corresponding to the storage position of the target picture and sending the target file path to the client;
in step S303, since the picture is large, loading the picture often needs a certain time to complete, but under the condition that the network is normal, the completion of loading the picture can be guaranteed within the preset time threshold. If the loading time is long due to the slow network speed, the Net Core waiting time is long, and the target picture acquisition request may be sent again to reload the picture. Further, in the process of waiting for the completion of the processing of the target picture acquisition request, recording the waiting time, and if the waiting time exceeds a preset time threshold, re-sending the target picture acquisition request to the server; and recording the sending times, and if the sending times exceed a preset time threshold, stopping sending the target picture acquisition request to the server side and feeding back downloading failure information to the client side.
Step S304: and if not, sending a new picture acquisition request to the server side and caching the new picture acquisition request into a preset resource downloading list.
Step S106: and if the target picture corresponding to the file name exists in the preset cache folder, acquiring a target file path for storing the target picture from the hash value and sending the target file path to the client.
In this embodiment, if the target picture is stored in the preset cache folder, the target picture can be directly obtained without downloading the target picture from the server, so that the resource obtaining time is saved, the request processing efficiency is improved, and the user experience is improved.
According to the dynamic picture caching method in the first embodiment of the invention, the resource request interface and the service request interface are separated at the client, so that the picture resource is ensured to be obtained from the resource request interface without blocking other service requests, and the overall request processing efficiency is improved; the downloaded picture resources are cached by deploying the picture buffer at the client, and the target picture is obtained by utilizing the file path, so that the picture calling efficiency is improved, and the problem of repeated downloading requests for refreshing the page is solved.
Fig. 4 is a flowchart illustrating a method for caching a moving picture according to a second embodiment of the present invention. It should be noted that the method of the present invention is not limited to the flow sequence shown in fig. 4 if the results are substantially the same. The method of the present invention is applied to a picture buffer running on a client, as shown in fig. 2, a client 21 interacts with a server 23, the client 21 is provided with the picture buffer 210, the picture buffer 210 is provided with a resource request interface 211 and a service request interface 212, and for the resource request interface 211, as shown in fig. 4, the method includes the steps of:
step S401: and receiving a target picture acquisition request sent by a user through a resource request interface.
In this embodiment, step S401 in fig. 4 is similar to step S101 in fig. 1, and for brevity, is not described herein again.
Step S402: and judging whether the target picture acquisition request is stored in a preset resource calling list or not, wherein the preset resource calling list stores the picture acquisition request in process.
In step S402, the Electron may request to acquire the same resource multiple times, which may result in multiple downloads of the same resource and conflict between the downloads if no processing is performed. Because the picture is large, calling the picture often needs a certain time to finish, and in addition, because the network speed is slow, the waiting time of the user is long, and the user may resend the picture acquisition request to attempt to acquire the picture. In order to solve the problem that a user refreshes to re-request to download a picture, the Net Core is provided with a preset resource calling list, and the picture acquisition request being processed can be cached through the preset resource calling list.
In this embodiment, by comparing whether the target picture obtaining request is the same as the picture obtaining request in the preset resource calling list, if so, it indicates that the target picture obtaining request already exists in the preset resource calling list and the target picture obtaining request is being processed, step S403 is executed, so as to avoid the problem that the obtaining duration is prolonged due to repeated requests; if not, it indicates that the target picture acquisition request does not exist in the preset resource calling list, and step S404 is executed.
Step S403: and if so, sending the target picture to the client after waiting for obtaining the target picture corresponding to the target picture obtaining request.
Step S404: if not, caching the target picture acquisition request into a preset resource calling list, and processing the target picture acquisition request to acquire a corresponding target picture.
In step S404, the manner of acquiring the corresponding target picture may be directly called from the local file of Net Core or downloaded from the server side for calling, and the specific acquisition manner is shown in steps S405 to S408.
Step S405: and calculating the hash value of the target picture acquisition request based on a hash algorithm.
In this embodiment, step S405 in fig. 4 is similar to step S102 in fig. 1, and for brevity, is not described herein again.
Step S406: and determining the file name of the target picture according to the hash value.
In this embodiment, step S406 in fig. 4 is similar to step S103 in fig. 1, and for brevity, is not described herein again.
Step S407: and judging whether a corresponding target picture exists in a preset cache folder of the picture cache according to the file name.
In this embodiment, step S407 in fig. 4 is similar to step S104 in fig. 1, and for brevity, is not described herein again.
Step S408: if the target picture corresponding to the file name does not exist in the preset cache folder, sending a target picture obtaining request to the server side, obtaining the target picture corresponding to the target picture obtaining request, storing the target picture in the preset cache folder, generating a target file path corresponding to the storage position of the target picture and sending the target file path to the client side.
In this embodiment, step S408 in fig. 4 is similar to step S105 in fig. 1, and for brevity, is not described herein again.
Step S409: and if the target picture corresponding to the file name exists in the preset cache folder, acquiring a target file path for storing the target picture from the hash value and sending the target file path to the client.
In this embodiment, step S409 in fig. 4 is similar to step S106 in fig. 1, and for brevity, is not described herein again.
The dynamic picture caching method of the second embodiment of the invention can cache the processed target picture obtaining request through the preset resource calling list on the basis of the first embodiment, and can process different target picture obtaining requests and wait for the same target picture obtaining request by comparing whether the target picture obtaining request is the same as the target picture obtaining request in the preset resource calling list, thereby solving the problem that a user refreshes to request for downloading pictures again.
Fig. 5 is a flowchart illustrating a method for caching a moving picture according to a third embodiment of the present invention. It should be noted that the method of the present invention is not limited to the flow sequence shown in fig. 5 if the results are substantially the same. The method of the present invention is applied to a picture buffer running on a client, as shown in fig. 2, a client 21 interacts with a server 23, the client 21 is provided with the picture buffer 210, the picture buffer 210 is provided with a resource request interface 211 and a service request interface 212, and as shown in fig. 5, for the service request interface 212, the method includes the steps of:
step S501: and receiving a service request sent by a user through a service request interface.
Step S502: and forwarding the service request to the server side to process the service request.
Step S503: and acquiring a processing result of the server and sending the processing result to the client.
In this embodiment, the number of requests of a Chrome kernel of an Electron is limited, the maximum concurrency number of requests of the same domain name is limited to 6, if Net Core only provides a service of a picture request, and no other service request processing is performed, the 6 concurrencies can be satisfied for use, but in order to expand the application range and compatibility, the Net Core also solves other service problems, and all situations that other service requests are blocked due to the fact that an unviewed picture needs to be downloaded from a server side are possible.
The dynamic picture caching method according to the third embodiment of the invention ensures that picture resources are obtained from the resource request interface without blocking other service requests by separating the resource request interface from the service request interface at the client, thereby improving the overall request processing efficiency.
FIG. 6 is a diagram illustrating a structure of a picture buffer according to an embodiment of the present invention. The image buffer is provided on the client, and as shown in fig. 6, the image buffer 60 includes a receiving module 61, a calculating module 62, a determining module 63, a determining module 64, a first obtaining module 65, and a second obtaining module 66. The picture buffer 50 is provided with a resource request interface and a service request interface.
The receiving module 61 is configured to receive a target picture obtaining request sent by a user through a resource request interface;
the calculating module 62 is configured to calculate a hash value of the target picture obtaining request based on a hash algorithm;
the determining module 63 is configured to determine a file name of the target picture according to the hash value;
the judging module 64 is configured to judge whether a corresponding target picture exists in a preset cache folder of the picture cache according to the file name;
the first obtaining module 65 is configured to, if a target picture corresponding to the file name does not exist in the preset cache folder, send a target picture obtaining request to the server, obtain a target picture corresponding to the target picture obtaining request, store the target picture in the preset cache folder, generate a target file path corresponding to a storage location of the target picture, and send the target file path to the client;
further, the first obtaining module 65 calculates a hash value according to the storage location of the target picture based on a hash algorithm, maps the hash value to a target file path for storing the target picture, sends the target file path to the client, and the client obtains the corresponding target picture according to the target file path. When the picture acquisition request URL for acquiring the target picture which is repeatedly refreshed or sent again by the user is acquired, the downloaded target picture is cached by deploying the picture buffer at the client, the target picture is acquired by utilizing the target file path, the picture calling efficiency is improved, and the problem of repeated downloading requests for refreshing the page is solved.
Further, in this embodiment, the target picture is stored in the preset cache folder, the preset cache folder is periodically scanned, and the corresponding cleaning operation is performed on the target picture stored in the preset cache folder according to the scanning result and the preset policy. Specifically, the preset policy includes: 1. acquiring the last access time of the target picture according to the scanning result, determining whether the target picture is an overdue cache file or not according to the last access time, and performing corresponding cleaning operation when the target picture is determined to be the overdue cache file; 2. and calculating the total capacity of all target pictures according to the scanning result, and if the total capacity exceeds a preset capacity threshold, removing the target pictures which are not accessed and the overdue cache files. By means of the method, the reading speed of the frequently accessed pictures can not be influenced, occupied space can be limited, and therefore picture obtaining efficiency is improved.
The second obtaining module 66 is configured to, if a target picture corresponding to the file name exists in the preset cache folder, obtain a target file path for storing the target picture from the hash value, and send the target file path to the client.
Referring to fig. 7, fig. 7 is a schematic structural diagram of a computer device according to an embodiment of the present invention. As shown in fig. 7, the computer device 70 includes a processor 71 and a memory 72 coupled to the processor 71.
The memory 72 stores program instructions for implementing the motion picture caching method according to any of the above embodiments.
The processor 71 is configured to execute program instructions stored in the memory 72 to cache motion pictures.
The processor 71 may also be referred to as a CPU (Central Processing Unit). The processor 71 may be an integrated circuit chip having signal processing capabilities. The processor 71 may also be a general purpose processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), an off-the-shelf programmable gate array (FPGA) or other programmable logic device, discrete gate or transistor logic, discrete hardware components. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
Referring to fig. 8, fig. 8 is a schematic structural diagram of a computer storage medium according to an embodiment of the present invention. The computer storage medium of the embodiment of the present invention stores a program file 81 capable of implementing all the methods described above, wherein the program file 81 may be stored in the computer storage medium in the form of a software product, and includes several instructions to enable a computer device (which may be a personal computer, a server, or a network device) or a processor (processor) to execute all or part of the steps of the methods described in the embodiments of the present invention. And the aforementioned computer storage media include: various media capable of storing program codes, such as a usb disk, a mobile hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, or terminal devices, such as a computer, a server, a mobile phone, and a tablet.
In the embodiments provided in the present invention, it should be understood that the disclosed system, apparatus and method may be implemented in other ways. For example, the above-described apparatus embodiments are merely illustrative, and for example, a division of a unit is merely a logical division, and an actual implementation may have another division, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
In addition, functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The above description is only an embodiment of the present invention, and not intended to limit the scope of the present invention, and all modifications of equivalent structures and equivalent processes, which are made by using the contents of the present specification and the accompanying drawings, or directly or indirectly applied to other related technical fields, are included in the scope of the present invention.

Claims (10)

1. A dynamic picture caching method is applied to a picture cache running on a client, wherein the picture cache is provided with a resource request interface and a service request interface, and the method comprises the following steps:
receiving a target picture acquisition request sent by a user through the resource request interface;
calculating a hash value of the target picture acquisition request based on a hash algorithm;
determining the file name of the target picture according to the hash value;
judging whether a corresponding target picture exists in a preset cache folder of the picture cache according to the file name;
if the target picture corresponding to the file name does not exist in the preset cache folder, sending the target picture obtaining request to a server side, obtaining the target picture corresponding to the target picture obtaining request, storing the target picture in the preset cache folder, generating a target file path corresponding to the storage position of the target picture and sending the target file path to the client side;
and if the target picture corresponding to the file name exists in the preset cache folder, acquiring a target file path for storing the target picture from the hash value and sending the target file path to the client.
2. The method according to claim 1, wherein if there is no target picture corresponding to the file name in the preset cache folder, the step of sending the target picture obtaining request to a server, obtaining the target picture corresponding to the target picture obtaining request, storing the target picture in the preset cache folder, generating a target file path corresponding to a storage location of the target picture, and sending the target file path to the client further comprises:
when the target picture acquisition request is sent to the server, storing the target picture acquisition request in a preset resource downloading list;
when a new picture acquisition request is sent to the server again, judging whether the new picture acquisition request is already stored in the preset resource downloading list or not;
if so, after the target picture acquisition request is processed, acquiring a target picture corresponding to the target picture acquisition request, storing the target picture in the preset cache folder, generating a target file path corresponding to the storage position of the target picture, and sending the target file path to the client;
and if not, sending a new picture acquisition request to the server side and caching the new picture acquisition request into the preset resource downloading list.
3. The method according to claim 2, wherein the step of waiting for the target picture acquisition request to be processed further comprises:
and recording waiting time in the process of waiting for the completion of the processing of the target picture acquisition request, and if the waiting time exceeds a preset time threshold, re-sending the target picture acquisition request to the server side.
4. The method according to claim 3, wherein after the step of resending the target picture retrieval request to the server, the method further comprises:
and recording the sending times, and if the sending times exceed a preset time threshold, stopping sending the target picture acquisition request to the server and feeding back downloading failure information to the client.
5. The method according to claim 1, further comprising, after receiving a target picture obtaining request sent by a user through the resource request interface:
judging whether the target picture acquisition request is stored in a preset resource calling list or not, wherein the preset resource calling list stores the picture acquisition request in process;
if so, after waiting for acquiring a target picture corresponding to the target picture acquisition request, sending the target picture to the client;
if not, caching the target picture acquisition request into the preset resource calling list, and processing the target picture acquisition request to acquire a corresponding target picture.
6. The method of claim 1, further comprising:
and scanning the preset cache folder regularly and carrying out corresponding cleaning operation on the target picture stored in the preset cache folder according to a scanning result and a preset strategy.
7. The method of claim 1, further comprising:
receiving a service request sent by the user through the service request interface;
forwarding the service request to a server side to process the service request;
and acquiring the processing result of the server and sending the processing result to the client.
8. The picture buffer is characterized in that the picture buffer is arranged on a client, the picture buffer is provided with a resource request interface and a service request interface, and the picture buffer comprises:
the receiving module is used for receiving a target picture acquisition request sent by a user through the resource request interface;
the calculation module is used for calculating a hash value of the target picture acquisition request based on a hash algorithm;
the determining module is used for determining the file name of the target picture according to the hash value;
the judging module is used for judging whether a corresponding target picture exists in a preset cache folder of the picture cache according to the file name;
a first obtaining module, configured to send a target picture obtaining request to a server if a target picture corresponding to the file name does not exist in the preset cache folder, obtain the target picture corresponding to the target picture obtaining request, store the target picture in the preset cache folder, generate a target file path corresponding to a storage location of the target picture, and send the target file path to the client;
and the second obtaining module is used for obtaining a target file path for storing the target picture from the hash value and sending the target file path to the client if the target picture corresponding to the file name exists in the preset cache folder.
9. A computer device, comprising: memory, processor and computer program stored on the memory and executable on the processor, characterized in that the processor implements the motion picture caching method according to any one of claims 1 to 7 when executing the computer program.
10. A computer storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the motion picture caching method as claimed in any one of claims 1 to 7.
CN202111137730.2A 2021-09-27 2021-09-27 Dynamic picture caching method, device, equipment and storage medium Pending CN113849753A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111137730.2A CN113849753A (en) 2021-09-27 2021-09-27 Dynamic picture caching method, device, equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111137730.2A CN113849753A (en) 2021-09-27 2021-09-27 Dynamic picture caching method, device, equipment and storage medium

Publications (1)

Publication Number Publication Date
CN113849753A true CN113849753A (en) 2021-12-28

Family

ID=78980201

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111137730.2A Pending CN113849753A (en) 2021-09-27 2021-09-27 Dynamic picture caching method, device, equipment and storage medium

Country Status (1)

Country Link
CN (1) CN113849753A (en)

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102282804A (en) * 2008-11-24 2011-12-14 瞻博网络公司 adaptive network content delivery system
CN102307234A (en) * 2011-08-24 2012-01-04 北京邮电大学 Resource retrieval method based on mobile terminal
JP2015165416A (en) * 2015-04-22 2015-09-17 株式会社 ディー・エヌ・エー Information terminal and data processing program
CN106095835A (en) * 2016-05-31 2016-11-09 广东能龙教育股份有限公司 Client side picture four-layer caching method
CN108197160A (en) * 2017-12-12 2018-06-22 腾讯科技(深圳)有限公司 A kind of picture loading method and device
CN109842610A (en) * 2018-12-13 2019-06-04 平安科技(深圳)有限公司 Interface requests processing method, device, computer equipment and storage medium
CN111597479A (en) * 2020-04-18 2020-08-28 北京奇保信安科技有限公司 Intelligent picture loading method and device for terminal and electronic equipment

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102282804A (en) * 2008-11-24 2011-12-14 瞻博网络公司 adaptive network content delivery system
CN102307234A (en) * 2011-08-24 2012-01-04 北京邮电大学 Resource retrieval method based on mobile terminal
JP2015165416A (en) * 2015-04-22 2015-09-17 株式会社 ディー・エヌ・エー Information terminal and data processing program
CN106095835A (en) * 2016-05-31 2016-11-09 广东能龙教育股份有限公司 Client side picture four-layer caching method
CN108197160A (en) * 2017-12-12 2018-06-22 腾讯科技(深圳)有限公司 A kind of picture loading method and device
CN109842610A (en) * 2018-12-13 2019-06-04 平安科技(深圳)有限公司 Interface requests processing method, device, computer equipment and storage medium
CN111597479A (en) * 2020-04-18 2020-08-28 北京奇保信安科技有限公司 Intelligent picture loading method and device for terminal and electronic equipment

Similar Documents

Publication Publication Date Title
CN110096660B (en) Method and device for loading page pictures and electronic equipment
CN108880921B (en) Webpage monitoring method and device, storage medium and server
US9185162B2 (en) System using server to synchronize document displayed on mobile devices
CN109992406B (en) Picture request method, picture request response method and client
US11811853B2 (en) Systems and methods for content delivery acceleration of virtual reality and augmented reality web pages
EP2948846A1 (en) Resource calling for hybrid applications
US20140208326A1 (en) File presenting method and apparatus for a smart terminal
US9088462B2 (en) Common web accessible data store for client side page processing
CN108197160B (en) Picture loading method and device
CN107798064B (en) Page processing method, electronic device and computer readable storage medium
CN104601534A (en) Method and system for processing CDN system images
CN107071007B (en) Method, device and client for obtaining configuration resources
CN108228816A (en) A kind of loading method and device of waterfall flow graph piece
CN111294372B (en) Method, device and system for realizing cache in proxy server
CN106446640B (en) User knows method for distinguishing and server
CN113536168B (en) Component processing method and device
CN112926002A (en) Service request processing method and device
CN111383038A (en) Advertisement display method and device of mobile terminal, mobile terminal and storage medium
CN108959393B (en) Dynamic picture processing method, device and storage medium
CN113849753A (en) Dynamic picture caching method, device, equipment and storage medium
CN113835789A (en) Rendering method, rendering device, electronic equipment and computer storage medium
US10068065B2 (en) Assignment of a machine-readable link to content as a payoff
US11379653B2 (en) Rendering method for on-demand loading of PDF file on network
CN112783548B (en) Access method and device of network system
CN114500484A (en) Page rendering method and device, electronic equipment and readable medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination