VOCacheProtocol
@protocol VOCacheProtocol
Objects that conform to the VOCachProtocol
will be responsible for saving objects in temporal storage.
-
The max number of items the cache supports.
Declaration
Objective-C
@property (assign, readwrite, nonatomic) int maxItems;
Swift
var maxItems: Int32 { get set }
-
Retrieves an object for an associated key from the cache.
Declaration
Objective-C
- (NSObject *)objectForKey:(NSString *)key;
Swift
func object(forKey key: String!) -> NSObject!
Parameters
key
- the key associated with the object.
Return Value
an object associated with the key.
-
Saves an object in cache with an associated key. If there is an existing object saved under this key, the new object will overwrite the previous.
Declaration
Objective-C
- (void)setObject:(NSObject *)object forKey:(NSString *)key;
Swift
func setObject(_ object: NSObject!, forKey key: String!)
Parameters
object
- the object being saved.
key
- the key associated with the object.
-
Saves an object in persistance with an associated key. If there is an existing object saved under this key, the new object will overwrite the previous.
Declaration
Objective-C
- (void)setObject:(NSObject *)object forKey:(NSString *)key shouldSaveToFileSystem:(BOOL)shouldSaveToFile lifeTime:(NSInteger)lifeTime;
Swift
func setObject(_ object: NSObject!, forKey key: String!, shouldSaveToFileSystem shouldSaveToFile: Bool, lifeTime: Int)
Parameters
object
- the object being saved.
key
- the key associated with the object.
shouldSaveToFile
- whether or not the item should be saved to the disk.
lifeTime
- how long the cache should save the object for.
-
Removes an object from the cache with associated key.
Declaration
Objective-C
- (void)removeObjectForKey:(NSString *)key;
Swift
func removeObject(forKey key: String!)
Parameters
key
- the key associated with the object.
-
Completely wipes everything in the cache including things saved to disk.
Declaration
Objective-C
- (void)removeAllData;
Swift
func removeAllData()
-
Removes all files from the cache’s file system.
Declaration
Objective-C
- (void)removeAllFromFileSystem;
Swift
func removeAllFromFileSystem()
-
Wipes everything in the cache memory, but keeps things saved to disk.
Declaration
Objective-C
- (void)removeAllInMemoryData;
Swift
func removeAllInMemoryData()
-
Retrieves everything from the cache’s file system and keeps it in memory for faster retrieval.
Declaration
Objective-C
- (void)restoreAllFromFileSystem;
Swift
func restoreAllFromFileSystem()