Use and view apicloud image cache clear cache

Source: Internet
Author: User

I. Cache list images

// Load and execute a function for caching images when circulating data
& Lt; script type = "text/x-dot-template" id = "listT" & gt;

{For (var I = 0; I <it. length; I ++ ){}}

{{};}}
& Lt;/script & gt;

// Executed function
Function fnLoadImage (ele _){
Var imageURL = $ api. attr (ele _, 'data-url ');
If (imageURL ){
Api. imageCache ({
Url: imageURL
}, Function (ret, err ){
If (ret. status ){
Ele _. src = ret. url;
$ Api. removeAttr (ele _, 'data _ url ');
            }
});
    }
}
II. Read cache and clear functions

// Template file
<Ul class = "aui-list-view">
<Li class = "aui-list-view-cell" tapmode onclick = "fn1_ache ()">
<A class = "aui-arrow-right">
Clear Cache
<Span class = "aui-badge-danger" id = 'cachesize'> </span>
</A>
</Li>
</Ul>

// Obtain the cache method
Function fnGetCacheSize (){
Api. getCacheSize (function (ret ){
Var size = parseInt (ret. size/1024/1024*100)/100 + 'mb ';
Var cacheSize = $ api. byId ('cachesize ');
CacheSize. innerHTML = size;
});
}

// Clear cache method
Function fn1_ache (){
Api. showProgress ({
Title: 'clearing cache ...',
});

Api. Sort ache (function (){
SetTimeout (function (){
Api. hideProgress ();
FnGetCacheSize ();
}, 500)
});
}
III. Monitor real-time changes in cache

// Listen for real-time cache changes in the callback method of frameGroup
If (ret. index = 3 ){
Var jsfun = 'fngetcachesize ();';
Api.exe cScript ({
FrameName: 'frame3 ',
Script: jsfun
});
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.