CacheWorker
internal class CacheWorker : NSDiscardableContent
An interface to the NSCache.
-
Implemented by subclasses to initialize a new object (the receiver) immediately after memory for it has been allocated.
Declaration
Swift
init()
-
A deinitializer is called immediately before a class instance is deallocated.
Declaration
Swift
deinit
-
An object representing the data store manager requesting this information.
Declaration
Swift
var dataStoreManager: DataStoreManager?
-
Asks the delegate for the cost with which associate to the object.
Declaration
Swift
var costDelegate: ((DataStoreManager, Any) -> Int)?
-
Undocumented
Declaration
Swift
func create(object: Any, forKey key: String, completionHandler: @escaping (_ isSuccessful: Bool, _ objectID: Any?, _ error: Error?) -> Void)
-
Undocumented
Declaration
Swift
func read(forKey key: String, completionHandler: @escaping (_ object: Any?, _ objectID: Any?, _ error: Error?) -> Void)
-
Undocumented
Declaration
Swift
func update(object: Any, forKey key: String, completionHandler: @escaping (_ isSuccessful: Bool, _ objectID: Any?, _ error: Error?) -> Void)
-
Undocumented
Declaration
Swift
func delete(forKey key: String, completionHandler: @escaping (_ isSuccessful: Bool, _ objectID: Any?, _ error: Error?) -> Void)
-
Undocumented
Declaration
Swift
func deleteAll(completionHandler: @escaping (_ isSuccessful: Bool, _ objectID: Any?, _ error: Error?) -> Void)
-
Returns a Boolean value indicating whether the discardable contents are still available and have been successfully accessed.
Call this method if the object’s memory is needed or is about to be used. This method increments the counter variable, thus protecting the object’s memory from possibly being discarded. The implementing class may decide that this method will try to recreate the contents if they have been discarded and return
true
if the re-creation was successful. Implementors of this protocol should raise exceptions if theNSDiscardableContent
objects are used when thebeginContentAccess
method has not been called on them.Declaration
Swift
func beginContentAccess() -> Bool
Return Value
true
if the discardable contents are still available and have now been successfully accessed; otherwise,false
. -
Called if the discardable contents are no longer being accessed.
This method decrements the counter variable of the object, which will usually bring the value of the counter variable back down to
0
, which allows the discardable contents of the object to be thrown away if necessary.Declaration
Swift
func endContentAccess()
-
Called to discard the contents of the receiver if the value of the accessed counter is
0
.This method should only discard the contents of the object if the value of the accessed counter is
0
. Otherwise, it should do nothing.Declaration
Swift
func discardContentIfPossible()
-
Returns a Boolean value indicating whether the content has been discarded.
Declaration
Swift
func isContentDiscarded() -> Bool
Return Value
true
if the content has been discarded; otherwise,false
.