CN109729165A - A kind of system and method for realizing file download using local cache strategy - Google Patents
A kind of system and method for realizing file download using local cache strategy Download PDFInfo
- Publication number
- CN109729165A CN109729165A CN201811622846.3A CN201811622846A CN109729165A CN 109729165 A CN109729165 A CN 109729165A CN 201811622846 A CN201811622846 A CN 201811622846A CN 109729165 A CN109729165 A CN 109729165A
- Authority
- CN
- China
- Prior art keywords
- downloading
- file
- network
- task
- class component
- 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.)
- Withdrawn
Links
Landscapes
- Information Transfer Between Computers (AREA)
Abstract
The present invention relates to a kind of system and methods that file download is realized using local cache strategy.System of the invention includes general framework class component, common tool class component, file tool class component, download tool class component;General framework class component realizes the basic operation of general framework, judges whether comprising file, whether has network;It opens the realization of common tool class component and compares two version sizes, the key for eliminating forbidden character, local cache being used to of a path is obtained, after adding random key behind url, for removing caching;File tool class component, which is realized, deletes file;Download tool class component mainly realizes local cache downloading file, timestamp, queue management and concurrent request management;The present invention can local cache method downloading network file after download parameters are arranged.The present invention, which is realized, downloads network file by local cache.
Description
Technical field
The present invention relates to computer application technologies, are realized under file more particularly to a kind of using local cache strategy
The system and method for load.
Background technique
Local cache is caching component in the application, its biggest advantage is that application and cache are in the same process
It is internal;Request caches very quick, not excessive network overhead etc..Cluster support or cluster situation are not needed in singly application
Under each node be not necessarily to it is appropriate using local cache under the scene that notifies mutually.
The cache policy of network file downloading is the then auto-returned HTTP 404 when the resource of server end does not change
Status code, content are sky, save transmitted data amount.When server-side code changes or restarts server, then again
Resource is sent, is returned similar when being requested with first time.To guarantee not repeat to client to issue resource, also guarantee to work as server
When changing, client can obtain newest resource.
It realizes the downloading of cache policy network file, is mainly based upon the warehouse plus and is managed, warehouse module management application
Local datastore area, preservation and reading for application data.It can be obtained by warehouse and manage object using local data,
The warehouse plus is also key-value pair data storage, is that OS is encapsulated one layer to JS to the key-value pair storing data library that primary App is used
It uses.
Summary of the invention
The technical issues of the application solves is to provide a kind of is using what local cache strategy realized network file downloading
System and method are realized and download network file by local cache.
The technical solution that the present invention solves above-mentioned technical problem is:
The system includes general framework class component, common tool class component, file tool class component, download tool class
Component;
The general framework class component realizes the basic operation of general framework, judges whether comprising file, whether has net
Network;
Two version sizes are compared in the common tool class component realization of opening, and obtain a path eliminates illegal word
Symbol, the key that local cache can be used to, after adding random key behind url, for removing caching;
The file tool class component, which is realized, deletes file;
The download tool class component is realized: local cache downloads file, increases memory, and it is locally slow to increase each
The effective time stamp deposited, customized setting method modify to parameter according to different demands, are downloaded using downloading queue
Management, increasing maximum concurrent request number prevents disposable requested more drain performances.
The method includes:
Download parameters are set;
Network file is downloaded by local cache method;
Described is specifically included by local cache method downloading network file:
S01, judgement need to not need to encode in path, encode if it is Chinese path to it;Otherwise under executing
One step;
S02, judge whether caching is expired;It is such as not out of date, then it performs the next step;If expired, jump to and obtained from network
It takes;
S03, check whether file is existing, and if so, directly adjusting back local path, taking local file, otherwise weigh
It is new to obtain;
S04, it is obtained from network, opens from network and download process.
The setting download parameters specifically include arranged below:
The downloading CACHE DIRECTORY of default is stored under the downloads/downloadFiles of application;
The timestamp of local cache is defaulted as 1 hour as unit of millisecond;
Downloader parallel downloading numbers most simultaneously, is defaulted as 5;
The timeout request time;
Number of retries after timeout request;
The maximum request time of single downloading task is defaulted 30 seconds as unit of millisecond;
Obtain the function of relative path;
The step-length of monitoring progress.
The unlatching is specifically included from network downloading process: being prepared network downloading and is downloaded by network;
The preparation network downloading is: addition enters in cache pool first;If having existed this cache pool, represent
This resource has made requests, it is only necessary to be filled into response pond;If not depositing cache pool, cache pool is created;If
Network state can be used, and network downloading process is entered through;
Described includes: creation downloading task by network downloading, addition progress monitor, starting downloading task, executes
Parallel downloading task.
The creation downloading task is to be passed to relative path when task is downloaded successfully, is cached for downloading successfully prompt
And it shows;When task failed download, local temporary files are deleted;Downloading is completed, and current task number subtracts 1, and reexamines down
Queue is carried, is removed from current downloading queue;
The addition progress monitor refers to the step-length for monitoring download progress;When monitoring step-length is 1, it is shown as " opening
Begin to download ";When monitoring step-length is 2, it is shown as " oneself is connected to server ";When the progress of monitoring is 3, it is shown as " downloading
In ", progress than degree every centainly showing once;When monitoring step-length is 4, display " downloading is completed ";
The execution parallel downloading task is recycled by queue and is carried out, if it is determined that current downloading task has timed, out,
And it is adjusted back without automatic trigger, then terminated task is downloaded, and is deleted from current task queue, and mistake readjustment is triggered;To presence
The task of time-out is rejected manually;If current downloading task is less than parallel downloading number, next task, current task are opened
Number is cumulative.
Using technical solution provided by the invention, have the advantages that
1, the technical solution that the present invention designs realizes cache policy file download, solves the problems, such as that caching is expired;
2, the present invention can be managed downloading task;
3, the present invention can monitor the step-length of download progress;
4, the present invention can parallel downloading project.
Detailed description of the invention
The following further describes the present invention with reference to the drawings:
Fig. 1 is that local cache of the invention realizes file download flow chart;
Fig. 2 is preparation network downloading flow chart of the invention;
Fig. 3 is network downloading document flowchart of the invention.
Specific embodiment
Following will be combined with the drawings in the embodiments of the present invention, and technical solution in the embodiment of the present invention carries out clear, complete
Whole description.
The present invention provides a kind of implementation method for realizing network file downloading using local cache strategy, function includes slow
It deposits strategy and realizes network file downloading, using the mode of local cache strategy, can preferentially use local cache in caching validity period.
Control management is carried out for the caching of each network file, increases timestamp parameter, to control the effective time of local cache.
All downloading tasks are put into queue, unified download management is carried out, increases maximum concurrent request number, prevents from disposably requesting
Excessive drain performance.It joined file cache pond mechanism, the network file of the same download path will not be downloaded repeatedly, and
It is filling cache pool, unified readjustment after downloading.It joined the processing for rejecting overtime task manually, always if there is a task
Completion is not downloaded, without triggering readjustment, task can be rejected in downloading next time, and trigger wrong readjustment yet.
Functional module of the invention includes general framework class component, common tool class component, file tool class component, downloading
Tool class component is constituted.
The general framework class component mainly includes the basic operation of general framework, need to judge whether comprising file,
Judge whether there is network etc.;
The common tool class component of opening includes comparing two version sizes, obtains this key of the key- of a path
Forbidden character is eliminated, local cache can be used to, random key will be added behind url, for removing caching, otherwise
The same url has caching, Delete Local File;
The file tool class component is primarily used to delete file;
The download tool class component is primarily used to local cache downloading file, increases storage, increases each
The effective time stamp of local cache increases customized setting method, can be modified according to different demands to parameter, uses
Downloading queue is downloaded management, increases maximum concurrent request number, prevent disposable requested more drain performances (attention: if
It may also change accordingly with picture tool class component and customized path downloading, the default parameters of download tool class component,
It needs manually he to be arranged to return);
Described method includes following steps:
Step 1: setting download parameters;
Step 2: network file is downloaded by local cache method;
Download parameters in the step 1 include:
1. the downloading CACHE DIRECTORY-of default is stored under the downloads/downloadFiles of application;
2. the timestamp of local cache, millisecond unit are defaulted as 1 hour;
3. downloader parallel downloading numbers most simultaneously, is defaulted as 5;
4. the timeout request time;
5. the number of retries after timeout request;
6. the single maximum request time of downloading task prevents from that wrong readjustment can not be triggered on some types, unit millisecond,
Default 30 seconds;
7. the function of relative path is obtained, if do not passed, then with the path processing method of default;
8. the step-length of the progress of monitoring.
The step 2 specifically includes: first determining whether not needing to encode in path, if it is Chinese path, need
It could be downloaded after encoding;Then judge whether caching is expired;Check whether file is existing, if there is just taking local text
Otherwise part reacquires;If file exists, then local path is directly adjusted back;If not using caching or caching
It is expired, it is obtained from network, opens from network and download process;
The network downloading process includes preparing network downloading, downloading two processes by network;
The preparation network downloading addition first enters in cache pool;If having existed this cache pool, this is represented
Resource has made requests, it is only necessary to be filled into response pond;If not depositing cache pool, cache pool is created;Then such as
Fruit network state can be used, and network downloading process is entered through;
Described downloads process including creating downloading task, addition progress monitor, starting downloading task, holding by network
Four steps of row parallel downloading task;
The creation downloading task when task is downloaded successfully, be passed to relative path, for download successfully prompt cache and
It shows;When task failed download, local temporary files need to be deleted, it is existing to check file when otherwise next time comes in;Under
It carries and completes, current task number subtracts 1, and reexamines downloading queue, removes from current downloading queue;
Addition progress monitor refers to the step-length for monitoring download progress;When monitoring step-length is 1, it is shown as " under starting
It carries ... ";When monitoring step-length is 2, it is shown as " oneself is connected to server ";When the progress of monitoring is 3, it is shown as " in downloading ",
Progress than degree every centainly showing once;When monitoring step-length is 4, display " downloading is completed ";
Executing parallel downloading task is to recycle to carry out by queue, is first determined whether if current downloading task has surpassed
When, and adjusted back without automatic trigger, terminated task downloading is deleted from current task queue, triggers mistake readjustment, there are super
When task, manually reject;If current downloading task is less than parallel downloading number, next task, current task number are opened
It is cumulative.
As shown in Figure 1, local cache of the invention realizes that network file downloading process is to first determine whether not needing road
Diameter is encoded, and if it is Chinese path, needs to download after encoding;Then judge whether caching is expired, if caching does not have
Have expired, and has used caching, checked whether file is existing, if there is local file is just taken, otherwise reacquires;
If file exists, then local path is directly adjusted back;If not expired using caching or caching, obtained from network.
As shown in Fig. 2, preparation network downloading process of the invention is to be added in cache pool first;If had existed
This cache pool represents this resource and has made requests, it is only necessary to be filled into response pond;If not depositing cache pool,
Newly-built cache pool;Then if network state can be used, networking downloading is carried out.
As shown in figure 3, network of the invention downloads document flow, comprising:
Step 1: creation downloading task;
Step 2: addition progress monitor;
Step 3: starting downloading task, addition enters in downloading queue;
Step 4: executing parallel downloading queue.
Claims (5)
1. a kind of system for realizing file download using local cache strategy, it is characterised in that: the system includes general frame
Frame class component, common tool class component, file tool class component, download tool class component;
The general framework class component realizes the basic operation of general framework, judges whether comprising file, whether has network;
It is described to open the realization of common tool class component and compare two version sizes, obtain a path eliminate forbidden character,
It can be used to the key of local cache, after adding random key behind url, for removing caching;
The file tool class component, which is realized, deletes file;
The download tool class component is realized: local cache downloads file, increases memory, increases each local cache
Effective time stamp, customized setting method modify to parameter according to different demands, are downloaded pipe using downloading queue
Reason, increasing maximum concurrent request number prevents disposable requested more drain performances.
2. a kind of method of system described in claim 1, it is characterised in that:
The method includes:
Download parameters are set;
Network file is downloaded by local cache method;
Described is specifically included by local cache method downloading network file:
S01, judgement need to not need to encode in path, encode if it is Chinese path to it;Otherwise it performs the next step;
S02, judge whether caching is expired;It is such as not out of date, then it performs the next step;If expired, jump to and obtained from network;
S03, check whether file is existing, and if so, directly adjusting back local path, taking local file, otherwise obtain again
It takes;
S04, it is obtained from network, opens from network and download process.
3. according to the method described in claim 2, it is characterized by:
The setting download parameters specifically include arranged below:
The downloading CACHE DIRECTORY of default is stored under the downloads/downloadFiles of application;
The timestamp of local cache is defaulted as 1 hour as unit of millisecond;
Downloader parallel downloading numbers most simultaneously, is defaulted as 5;
The timeout request time;
Number of retries after timeout request;
The maximum request time of single downloading task is defaulted 30 seconds as unit of millisecond;
Obtain the function of relative path;
The step-length of monitoring progress.
4. according to the method described in claim 2, it is characterized by:
The unlatching is specifically included from network downloading process: being prepared network downloading and is downloaded by network;
The preparation network downloading is: addition enters in cache pool first;If having existed this cache pool, this is represented
Resource has made requests, it is only necessary to be filled into response pond;If not depositing cache pool, cache pool is created;If network
State can be used, and network downloading process is entered through;
Described being downloaded by network includes: creation downloading task, addition progress monitor, starting downloading task, executes concurrently
Downloading task.
5. according to the method described in claim 4, it is characterized by:
The creation downloading task is to be passed to relative path when task is downloaded successfully, caches and opens up for downloading successfully prompt
Show;When task failed download, local temporary files are deleted;Downloading is completed, and current task number subtracts 1, and reexamines downloading team
Column are removed from current downloading queue;
The addition progress monitor refers to the step-length for monitoring download progress;When monitoring step-length is 1, it is shown as " under starting
It carries ";When monitoring step-length is 2, it is shown as " oneself is connected to server ";When the progress of monitoring is 3, it is shown as " in downloading ", into
Degree than degree every centainly showing once;When monitoring step-length is 4, display " downloading is completed ";
The execution parallel downloading task is recycled by queue and is carried out, if it is determined that current downloading task has timed, out, and
There is no automatic trigger readjustment, then terminated task is downloaded, and is deleted from current task queue, and mistake readjustment is triggered;It is overtime to existing
Task, manually reject;If current downloading task is less than parallel downloading number, next task is opened, current task number is tired
Add.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201811622846.3A CN109729165A (en) | 2018-12-28 | 2018-12-28 | A kind of system and method for realizing file download using local cache strategy |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201811622846.3A CN109729165A (en) | 2018-12-28 | 2018-12-28 | A kind of system and method for realizing file download using local cache strategy |
Publications (1)
Publication Number | Publication Date |
---|---|
CN109729165A true CN109729165A (en) | 2019-05-07 |
Family
ID=66295977
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201811622846.3A Withdrawn CN109729165A (en) | 2018-12-28 | 2018-12-28 | A kind of system and method for realizing file download using local cache strategy |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN109729165A (en) |
Citations (9)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102109989A (en) * | 2009-12-29 | 2011-06-29 | 阿里巴巴集团控股有限公司 | Method, device and system for controlling browser cache |
CN102970358A (en) * | 2012-11-08 | 2013-03-13 | 百度在线网络技术(北京)有限公司 | Method and device for controlling local cache of mobile client in network disc |
CN104735112A (en) * | 2013-12-23 | 2015-06-24 | 阿里巴巴集团控股有限公司 | Resource file sending method and resource file caching method and device |
CN106250061A (en) * | 2016-08-12 | 2016-12-21 | 乐视控股(北京)有限公司 | File download processing method and processing device |
US20170154053A1 (en) * | 2001-12-28 | 2017-06-01 | Open Text Sa Ulc | System and method for the synchronization of a file in a cache |
CN108012030A (en) * | 2017-11-30 | 2018-05-08 | 北京酷我科技有限公司 | A kind of mobile terminal downloading management method |
CN108595188A (en) * | 2018-03-30 | 2018-09-28 | 北京五八信息技术有限公司 | A kind of acquisition methods of application file, device, equipment and storage medium |
US10146788B1 (en) * | 2014-10-10 | 2018-12-04 | Google Llc | Combined mirroring and caching network file system |
CN108965407A (en) * | 2018-07-02 | 2018-12-07 | 广东飞企互联科技股份有限公司 | A kind of processing implementation method of mobile Internet file download |
-
2018
- 2018-12-28 CN CN201811622846.3A patent/CN109729165A/en not_active Withdrawn
Patent Citations (9)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20170154053A1 (en) * | 2001-12-28 | 2017-06-01 | Open Text Sa Ulc | System and method for the synchronization of a file in a cache |
CN102109989A (en) * | 2009-12-29 | 2011-06-29 | 阿里巴巴集团控股有限公司 | Method, device and system for controlling browser cache |
CN102970358A (en) * | 2012-11-08 | 2013-03-13 | 百度在线网络技术(北京)有限公司 | Method and device for controlling local cache of mobile client in network disc |
CN104735112A (en) * | 2013-12-23 | 2015-06-24 | 阿里巴巴集团控股有限公司 | Resource file sending method and resource file caching method and device |
US10146788B1 (en) * | 2014-10-10 | 2018-12-04 | Google Llc | Combined mirroring and caching network file system |
CN106250061A (en) * | 2016-08-12 | 2016-12-21 | 乐视控股(北京)有限公司 | File download processing method and processing device |
CN108012030A (en) * | 2017-11-30 | 2018-05-08 | 北京酷我科技有限公司 | A kind of mobile terminal downloading management method |
CN108595188A (en) * | 2018-03-30 | 2018-09-28 | 北京五八信息技术有限公司 | A kind of acquisition methods of application file, device, equipment and storage medium |
CN108965407A (en) * | 2018-07-02 | 2018-12-07 | 广东飞企互联科技股份有限公司 | A kind of processing implementation method of mobile Internet file download |
Non-Patent Citations (1)
Title |
---|
谢磊,吴建华等: "一种基于LRFU缓存替换策略的HDFS客户端本地缓存设计与实现", 《计算机应用与软件 软件技术与研究》 * |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
RU2453911C2 (en) | Offline execution of web based applications | |
US20200351346A1 (en) | File service using a shared file access-rest interface | |
US11249856B2 (en) | Application consistent snapshots as a sidecar of a containerized application | |
US9588977B1 (en) | Data and metadata structures for use in tiering data to cloud storage | |
US9959280B1 (en) | Garbage collection of data tiered to cloud storage | |
CN106951233B (en) | Mixed-mode smart phone application development framework system | |
US7676554B1 (en) | Network acceleration device having persistent in-memory cache | |
KR101953942B1 (en) | System and method for managing dedicated caches | |
US9274896B2 (en) | Versioned file system with fast restore | |
CN104767834B (en) | System and method for the transmission for accelerating to calculate environment to remote user | |
US11188561B2 (en) | Prioritizing microservices on a container platform for a restore operation | |
US20070143379A1 (en) | Metadata driven deployment of applications | |
US20110083138A1 (en) | Self-service configuration for data environment | |
CA2782674A1 (en) | System and method for providing virtual web access | |
US9645809B2 (en) | Updating software components through online stores | |
CN101656751A (en) | Method and system for accelerating file uploading and downloading | |
US10802801B1 (en) | Grand unified processor | |
WO2016127656A1 (en) | Data caching method and device for net disk client | |
CN109729165A (en) | A kind of system and method for realizing file download using local cache strategy | |
US11669318B2 (en) | Rapid software provisioning and patching | |
US20230118118A1 (en) | Client-based name cache handling external to distributed storage system | |
US20130275542A1 (en) | Online Game System and Method | |
US11017032B1 (en) | Document recovery utilizing serialized data | |
CN111753231B (en) | Method and device for loading third-party H5 page and computer readable storage medium | |
US11609749B1 (en) | Grand unified processor with adaptive processing features |
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 | ||
WW01 | Invention patent application withdrawn after publication |
Application publication date: 20190507 |
|
WW01 | Invention patent application withdrawn after publication |