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
handling
The type of QueueJob this persister will handle
queueName
The 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]) throws
Parameters
jobs
The 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) throws
Parameters
job
The 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
completion
The block to call after the attempt to clear all jobs is complete.