MBFilesystemCacheDelegate Protocol Reference
Declared in | MBFilesystemCache.h |
---|
Overview
This protocol is adopted by classes that wish to control the behavior of an
MBFilesystemCache
instance.
Other Methods
– filenameForCacheKey:
required method
Called by the MBFilesystemCache
to create a filename for a given cache
key.
- (nonnull NSString *)filenameForCacheKey:(nonnull id)key
Parameters
key |
The cache key for which the filename is sought. |
---|
Return Value
The filename for the given cache key.
Discussion
The cache object associated with the given key will be stored in a file with the name returned by this method.
Declared In
MBFilesystemCache.h
Converting cache objects to and from raw data
– cacheDataFromObject:
Converts the specified cache object into an NSData
instance that can be
written to a file.
- (nullable NSData *)cacheDataFromObject:(nonnull id)cacheObj
Parameters
cacheObj |
The cache object for which the raw data should be returned. |
---|
Return Value
An NSData
representation of the given cache object, or nil
if
it could not be created.
Discussion
Note: If cache objects are stored as NSData
instances directly,
the delegate does not need to implement this method.
Declared In
MBFilesystemCache.h
– objectFromCacheData:
Converts raw data representing a cache object into the cache object itself. Used to convert a file into an object.
- (nullable id)objectFromCacheData:(nonnull NSData *)cacheData
Parameters
cacheData |
The raw data representing the cache object. |
---|
Return Value
The cache object created from the raw cache data, or nil
if it could not be created.
Discussion
Note: If cache objects are stored as NSData
instances directly,
the delegate does not need to implement this method.
Declared In
MBFilesystemCache.h
Controlling what gets stored in the cache
– shouldStoreObject:forKey:inMemoryCache:
Asks the delegate whether or not the specified object should be stored in the memory cache.
- (BOOL)shouldStoreObject:(nonnull id)cacheObj forKey:(nonnull id)key inMemoryCache:(nonnull MBFilesystemCache *)cache
Parameters
cacheObj |
The object that may be stored in the memory cache. |
---|---|
key |
The cache key associated with |
cache |
The |
Return Value
YES
if the cacheObj
should be stored in the memory cache of
cache
; NO
otherwise.
Discussion
Note: If the delegate does not implement this method, objects will always be stored in the memory cache.
Declared In
MBFilesystemCache.h
– shouldStoreObject:forKey:inFilesystemCache:
Asks the delegate whether or not the specified object should be stored in the filesystem cache.
- (BOOL)shouldStoreObject:(nonnull id)cacheObj forKey:(nonnull id)key inFilesystemCache:(nonnull MBFilesystemCache *)cache
Parameters
cacheObj |
The object that may be stored in the filesystem cache. |
---|---|
key |
The cache key associated with |
cache |
The |
Return Value
YES
if the cacheObj
should be stored in the filesystem cache of
cache
; NO
otherwise.
Discussion
Note: If the delegate does not implement this method, objects will always be stored in the filesystem cache.
Declared In
MBFilesystemCache.h