Config

public struct Config

Represents the config used in a DiskStorage.

  • The file size limit on disk of the storage in bytes. 0 means no limit.

    Declaration

    Swift

    public var sizeLimit: UInt
  • The StorageExpiration used in this disk storage. Default is .days(7), means that the disk cache would expire in one week.

    Declaration

    Swift

    public var expiration: StorageExpiration
  • The preferred extension of cache item. It will be appended to the file name as its extension. Default is nil, means that the cache file does not contain a file extension.

    Declaration

    Swift

    public var pathExtension: String?
  • Default is true, means that the cache file name will be hashed before storing.

    Declaration

    Swift

    public var usesHashedFileName: Bool
  • Creates a config value based on given parameters.

    Declaration

    Swift

    public init(
        name: String,
        sizeLimit: UInt,
        fileManager: FileManager = .default,
        directory: URL? = nil)

    Parameters

    name

    The name of cache. It is used as a part of storage folder. It is used to identify the disk storage. Two storages with the same name would share the same folder in disk, and it should be prevented.

    sizeLimit

    The size limit in bytes for all existing files in the disk storage.

    fileManager

    The FileManager used to manipulate files on disk. Default is FileManager.default.

    directory

    The URL where the disk storage should live. The storage will use this as the root folder, and append a path which is constructed by input name. Default is nil, indicates that the cache directory under user domain mask will be used.