Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Sources/SPTPersistentCache.m
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ - (instancetype)init
return [self initWithOptions:[SPTPersistentCacheOptions new]];
}

- (nullable instancetype)initFailableWithOptions:(SPTPersistentCacheOptions *)options
{
return [self initWithOptions:options];
}

- (instancetype)initWithOptions:(SPTPersistentCacheOptions *)options
{
self = [super init];
Expand Down
2 changes: 1 addition & 1 deletion Tests/SPTPersistentCacheTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -1270,7 +1270,7 @@ - (void)testInitNilWhenCannotCreateCacheDirectory
return nil;
});
method_setImplementation(originalMethod, fakeMethodImplementation);
SPTPersistentCache *cache = [[SPTPersistentCache alloc] initWithOptions:options];
SPTPersistentCache *cache = [[SPTPersistentCache alloc] initFailableWithOptions:options];
method_setImplementation(originalMethod, originalMethodImplementation);

XCTAssertNil(cache, @"The cache should be nil if it could not create the directory");
Expand Down
7 changes: 7 additions & 0 deletions include/SPTPersistentCache/SPTPersistentCacheImplementation.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,13 @@ typedef NSString * _Nonnull(^SPTPersistentCacheChooseKeyCallback)(NSArray<NSStri
*/
- (instancetype)initWithOptions:(SPTPersistentCacheOptions *)options NS_DESIGNATED_INITIALIZER;

/**
Failable initialiser.
@param options The options to use for the cache parameters.
@return An initialised cache, or `nil` if the cache directory cannot be created.
*/
- (nullable instancetype)initFailableWithOptions:(SPTPersistentCacheOptions *)options;

/**
@discussion Load data from cache for specified key.
Req.#1.2. Expired records treated as not found on load. (And open stream)
Expand Down