Skip to content
Open
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
3 changes: 2 additions & 1 deletion Sources/SPTPersistentCache.m
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,8 @@ - (void)loadDataForKeySync:(NSString *)key
SPTPersistentCacheRecord *record = [[SPTPersistentCacheRecord alloc] initWithData:payload
key:key
refCount:refCount
ttl:ttl];
ttl:ttl
updateTime:localHeader.updateTimeSec];

SPTPersistentCacheResponse *response = [[SPTPersistentCacheResponse alloc] initWithResult:SPTPersistentCacheResponseCodeOperationSucceeded
error:nil
Expand Down
5 changes: 5 additions & 0 deletions Sources/SPTPersistentCacheRecord+Private.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,9 @@
refCount:(NSUInteger)refCount
ttl:(NSUInteger)ttl;

- (instancetype)initWithData:(NSData *)data
key:(NSString *)key
refCount:(NSUInteger)refCount
ttl:(NSUInteger)ttl
updateTime:(NSUInteger)updateTime;
@end
12 changes: 11 additions & 1 deletion Sources/SPTPersistentCacheRecord.m
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,23 @@ - (instancetype)initWithData:(NSData *)data
key:(NSString *)key
refCount:(NSUInteger)refCount
ttl:(NSUInteger)ttl
{
return [self initWithData:data key:key refCount:refCount ttl:ttl updateTime:0];
}

- (instancetype)initWithData:(NSData *)data
key:(NSString *)key
refCount:(NSUInteger)refCount
ttl:(NSUInteger)ttl
updateTime:(NSUInteger)updateTime
{
self = [super init];
if (self) {
_refCount = refCount;
_ttl = ttl;
_key = [key copy];
_data = data;
_updateTime = updateTime;
}
return self;
}
Expand All @@ -49,7 +59,7 @@ - (NSString *)description

- (NSString *)debugDescription
{
return SPTPersistentCacheObjectDescription(self, self.key, @"key", @(self.ttl), @"ttl", @(self.refCount), @"ref-count");
return SPTPersistentCacheObjectDescription(self, self.key, @"key", @(self.ttl), @"ttl", @(self.updateTime), @"updated", @(self.refCount), @"ref-count");
}

@end
4 changes: 4 additions & 0 deletions include/SPTPersistentCache/SPTPersistentCacheRecord.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ NS_ASSUME_NONNULL_BEGIN
Data that was initially passed into storeData:...
*/
@property (nonatomic, strong, readonly) NSData *data;
/*
* Update time of the record (when it was last stored or accessed)
*/
@property (nonatomic, assign, readonly) NSUInteger updateTime;

@end

Expand Down
Loading