FileBasedPersister
public class FileBasedPersister<HandlingJob: QueueJob>: JobPersister
A JobPersister which persists QueueJobs to the device’s local file system
-
Provides the path to where this Persister is performing its IO.
Declaration
Swift
public var persistenceLocation: String -
Initializes this JobPersister
Declaration
Swift
public init(handling: HandlingJob.Type, queueName: String)Parameters
handlingThe type of QueueJob this persister will handle
queueNameThe name of the queue this persister is saving jobs for.
-
Writes a JSONEncoded version of the QueueJobs to the
Application Support/Cute/Queues/[Queue Name]directoryThrows
An error any of the jobs fail to persist.Declaration
Swift
public func persist(_ jobs: [HandlingJob]) throwsParameters
jobsThe QueueJobs to persist
-
Deletes the job’s persisted file from disk
Throws
An error if the job’s persiste file fails to delete.Declaration
Swift
public func delete(_ job: HandlingJob) throwsParameters
jobThe job whose persisted file is to be deleted
-
Loads all jobs from file in the correct order
Throws
An error if any of the jobs failed to load from disk.Declaration
Swift
public func load() throws -> [HandlingJob]Return Value
The array of jobs loaded from disk, in their correct order
-
Clears all persisted jobs from disk
Declaration
Swift
public func clear(completion: ((Error?) -> Void)?)Parameters
completionThe block to call after the attempt to clear all jobs is complete.
View on GitHub
FileBasedPersister Class Reference