Clear the implementation of the cache

Source: Internet
Author: User

 //Calculate cache size on child threadsDispatch_async (Dispatch_get_global_queue (0,0), ^{//get the Cache folder pathUnsignedLong LongSize =file.filesize; Size+=[Sdimagecache sharedimagecache].getsize; NSString*sizetext =Nil; if(Size >= Pow (Ten,9)) {//size >= 1GBSizetext = [NSString stringWithFormat:@"%.2FGB", Size/pow (Ten,9)]; } Else if(Size >= Pow (Ten,6)) {//1GB > Size >= 1MBSizetext = [NSString stringWithFormat:@"%.2FMB", Size/pow (Ten,6)]; } Else if(Size >= Pow (Ten,3)) {//1MB > Size >= 1KBSizetext = [NSString stringWithFormat:@"%.2fkb", Size/pow (Ten,3)]; } Else{//1KB > SizeSizetext = [NSString stringWithFormat:@"%zdb", size]; }//Generate textNSString *text = [NSString stringWithFormat:@"Clear Cache (%@)", Sizetext]; //back to main threadDispatch_async (Dispatch_get_main_queue (), ^{                //Set Text              //Restore Click eventsself.userinteractionenabled =YES;        });    }); }    returnSelf ;}
/** * Clear Cache*/- (void) clearcache{//Popup Indicator[Svprogresshud Showwithstatus:@"Clearing cache ..."Masktype:svprogresshudmasktypeblack]; //Delete the sdwebimage cache[[Sdimagecache Sharedimagecache] cleardiskoncompletion:^{        //Delete a custom cacheDispatch_async (Dispatch_get_global_queue (0,0), ^{Nsfilemanager*mgr =[Nsfilemanager Defaultmanager];            [Mgr Removeitematpath:file Error:nil];            [Mgr Createdirectoryatpath:xmgcustomcachefile withintermediatedirectories:yes attributes:nil Error:nil]; //all caches are cleared.Dispatch_async (Dispatch_get_main_queue (), ^{                //Hide Indicator[Svprogresshud dismiss]; //Set TextSelf.textLabel.text =@"Clear Cache (0B)";        });    }); }];}

Clear the implementation of the cache

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.