BUCacheManager.h
1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
//
// BUCacheManager.h
// BUAdSDK
//
// Created by 李盛 on 2018/9/19.
// Copyright © 2018年 bytedance. All rights reserved.
//
#import <Foundation/Foundation.h>
extern NSString *BUCacheConfigurationKey;
extern NSString *BUCacheFinishedErrorKey;
@class BUCacheConfiguration;
@interface BUCacheManager : NSObject
+ (void)setCacheDirectory:(NSString *)cacheDirectory;
+ (NSString *)cacheDirectory;
/**
How often trigger `BUCacheManagerDidUpdateCacheNotification` notification
@param interval Minimum interval
*/
+ (void)setCacheUpdateNotifyInterval:(NSTimeInterval)interval;
+ (NSTimeInterval)cacheUpdateNotifyInterval;
+ (NSString *)cachedFilePathForURL:(NSURL *)url;
+ (BUCacheConfiguration *)cacheConfigurationForURL:(NSURL *)url;
+ (void)setFileNameRules:(NSString *(^)(NSURL *rulesUrl))rules;
/**
Calculate cached files size
@param error If error not empty, calculate failed
@return files size, respresent by `byte`, if error occurs, return -1
*/
+ (unsigned long long)calculateCachedSizeWithError:(NSError **)error;
+ (BOOL)cleanAllCacheWithError:(NSError **)error;
+ (BOOL)cleanCacheForURL:(NSURL *)url error:(NSError **)error;
/**
Useful when you upload a local file to the server
@param filePath local file path
@param url remote resource url
@param error On input, a pointer to an error object. If an error occurs, this pointer is set to an actual error object containing the error information.
*/
+ (BOOL)addCacheFile:(NSString *)filePath forURL:(NSURL *)url error:(NSError **)error;
@end