Skip to content

Commit

Permalink
DRY up a couple of constants
Browse files Browse the repository at this point in the history
  • Loading branch information
andyfinnell committed May 2, 2024
1 parent fb518cb commit fb6eb1f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Source/PINCache.m
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ - (instancetype)initWithName:(NSString *)name
keyDecoder:keyDecoder
operationQueue:_operationQueue
ttlCache:ttlCache
byteLimit:50 * 1024 * 1024 // 50 MB by default
ageLimit:60 * 60 * 24 * 30 // 30 days by default
byteLimit:PINDiskCacheDefaultByteLimit
ageLimit:PINDiskCacheDefaultAgeLimit
evictionStrategy:evictionStrategy];
_memoryCache = [[PINMemoryCache alloc] initWithName:_name operationQueue:_operationQueue ttlCache:ttlCache evictionStrategy:evictionStrategy];
}
Expand Down
3 changes: 3 additions & 0 deletions Source/PINDiskCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ extern NSErrorUserInfoKey const PINDiskCacheErrorReadFailureCodeKey;
extern NSErrorUserInfoKey const PINDiskCacheErrorWriteFailureCodeKey;
extern NSString * const PINDiskCachePrefix;

extern NSUInteger PINDiskCacheDefaultByteLimit;
extern NSTimeInterval PINDiskCacheDefaultAgeLimit;

typedef NS_ENUM(NSInteger, PINDiskCacheError) {
PINDiskCacheErrorReadFailure = -1000,
PINDiskCacheErrorWriteFailure = -1001,
Expand Down
7 changes: 5 additions & 2 deletions Source/PINDiskCache.m
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
NSString * const PINDiskCachePrefix = @"com.pinterest.PINDiskCache";
static NSString * const PINDiskCacheSharedName = @"PINDiskCacheShared";

NSUInteger PINDiskCacheDefaultByteLimit = 50 * 1024 * 1024; // 50 MB by default
NSTimeInterval PINDiskCacheDefaultAgeLimit = 60 * 60 * 24 * 30; // 30 days by default

static NSString * const PINDiskCacheOperationIdentifierTrimToDate = @"PINDiskCacheOperationIdentifierTrimToDate";
static NSString * const PINDiskCacheOperationIdentifierTrimToSize = @"PINDiskCacheOperationIdentifierTrimToSize";
static NSString * const PINDiskCacheOperationIdentifierTrimToSizeByDate = @"PINDiskCacheOperationIdentifierTrimToSizeByDate";
Expand Down Expand Up @@ -200,8 +203,8 @@ - (instancetype)initWithName:(NSString *)name
keyDecoder:keyDecoder
operationQueue:operationQueue
ttlCache:ttlCache
byteLimit:50 * 1024 * 1024 // 50 MB by default
ageLimit:60 * 60 * 24 * 30]; // 30 days by default
byteLimit:PINDiskCacheDefaultByteLimit
ageLimit:PINDiskCacheDefaultAgeLimit];
}

- (instancetype)initWithName:(nonnull NSString *)name
Expand Down

0 comments on commit fb6eb1f

Please sign in to comment.