Closed wiseoldduck closed 5 years ago
Yes, it also happens in sharedCache. The TTL support in latest code is confusing.
Agreed, it's confusing - I ran into issues once I adopted it - my previous custom cache started deleting the disk cache upon instantiation of the Manager. I think because I hadn't adopted the optional Protocol.
Also, shouldn't there be away to turn on TTL for the shared cache of the default Manager? otherwise it's impossible to get ageLimit
working.
- (instancetype)initWithName:(nonnull NSString *)name rootPath:(nonnull NSString *)rootPath serializer:(nullable PINDiskCacheSerializerBlock)serializer deserializer:(nullable PINDiskCacheDeserializerBlock)deserializer keyEncoder:(nullable PINDiskCacheKeyEncoderBlock)keyEncoder keyDecoder:(nullable PINDiskCacheKeyDecoderBlock)keyDecoder ttlCache:(BOOL)ttlCache NS_DESIGNATED_INITIALIZER;
passing
ttlCache:YES
here only enables ttlCache for the disk cache, the memory cache is still set up as a non-ttl cache.This can be corrected after the fact with PINMemoryCache:
- (void)setTtlCache:(BOOL)ttlCache DEPRECATED_MSG_ATTRIBUTE("ttlCache is no longer a settable property and must now be set via initializer.");
but, this is unintuitive, and as you can see this method is marked as deprecated.