PSPDFDiskCache


@interface PSPDFDiskCache : NSObject

The disk cache persists its metadata on disk together with the images and provides cached images even after the app restarts.

The disk cache is designed to store and fetch images, including metadata, in a fast way. No actual images will be held in memory (besides during the time they are scheduled for writing to disk).

  • Undocumented

    Declaration

    Objective-C

    
    @interface PSPDFDiskCache : NSObject
  • Undocumented

    Declaration

    Objective-C

    
    @interface PSPDFDiskCache : NSObject
  • Initializes the disk cache with the specified directory and the file format.

    Declaration

    Objective-C

    - (nonnull instancetype)
    initWithCacheDirectory:(nonnull NSString *)cacheDirectory
                fileFormat:(PSPDFDiskCacheFileFormat)fileFormat
                  settings:(nonnull PSPDFKit *)settings;

    Swift

    init(cacheDirectory: String, fileFormat: PSPDFDiskCacheFileFormat, settings: PSPDFKit)

    Parameters

    cacheDirectory

    The directory that should be used for this cache, relative to the app’s cache directory.

    fileFormat

    The file format to use for storing images to disk.

    settings

    The settings used to create the cache.

    Return Value

    A newly initialized disk cache.

  • The maximum amount of disk space the cache is allowed to use (in bytes).

    This value is a non strict maximum value. The cache might also start evicting images before this limit is reached, depending on the memory and disk state of the device.

    Note

    Set to 0 to disable the disk cache.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) long long allowedDiskSpace;

    Swift

    var allowedDiskSpace: Int64 { get set }
  • The disk space currently used by the cache (in bytes).

    Declaration

    Objective-C

    @property (readonly, nonatomic) long long usedDiskSpace;

    Swift

    var usedDiskSpace: Int64 { get }
  • The directory this cache uses.

    Declaration

    Objective-C

    @property (readwrite, copy, nonatomic) NSString *_Nonnull cacheDirectory;

    Swift

    var cacheDirectory: String { get set }
  • The file format used to store images.

    Defaults to jpeg.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) PSPDFDiskCacheFileFormat fileFormat;

    Swift

    var fileFormat: PSPDFDiskCacheFileFormat { get set }
  • If the file format is jpeg, this controls the quality (from 0.0 = bad to 1.0 = best).

    Defaults to 0.9.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) CGFloat jpegCompression;

    Swift

    var jpegCompression: CGFloat { get set }
  • A block that is called to encrypt data before storing it to the disk.

    Note

    This block is called on an arbitrary, concurrent background queue.

    Declaration

    Objective-C

    @property (readwrite, copy, nonatomic, nullable) NSData *_Nullable (^)
        (PSPDFRenderRequest *_Nonnull, NSData *_Nonnull) encryptionHelper;

    Swift

    var encryptionHelper: ((PSPDFRenderRequest, Data) -> Data?)? { get set }
  • A block that is called to decrypt data that was previously encrypted via the encryption helper.

    Note

    This block is called on an arbitrary, concurrent background queue.

    Declaration

    Objective-C

    @property (readwrite, copy, nonatomic, nullable) NSData *_Nullable (^)
        (PSPDFRenderRequest *_Nonnull, NSData *_Nonnull) decryptionHelper;

    Swift

    var decryptionHelper: ((PSPDFRenderRequest, Data) -> Data?)? { get set }