PSPDFDiskCache

Objective-C


@interface PSPDFDiskCache : NSObject

Swift

class DiskCache : 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).

The disk cache can be accessed with PSPDFKit.SDK.shared.cache.diskCache.

  • Unavailable

    Not the designated initializer

    Undocumented

    Declaration

    Objective-C

    PSPDF_EMPTY_INIT_UNAVAILABLE
  • Unavailable

    Not the designated initializer

    Undocumented

    Declaration

    Objective-C

    PSPDF_EMPTY_INIT_UNAVAILABLE
  • 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 (nonatomic) long long allowedDiskSpace;

    Swift

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

    Declaration

    Objective-C

    @property (nonatomic, readonly) long long usedDiskSpace;

    Swift

    var usedDiskSpace: Int64 { get }
  • The directory this disk cache uses to store and load images.

    The default value is <iOS Caches Directory>/PSPDFKit/Pages. The iOS Caches Directory is obtained by calling NSSearchPathForDirectoriesInDomains. Example: /var/mobile/Containers/Data/Application/<UUID>/Library/Caches/PSPDFKit/Pages.

    Note

    This directory is automatically created upon first cache write. Clearing the cache will delete all sub-directories, but not the directory itself.

    You can manually create this directory and set a custom iOS Data Protection level.

    Declaration

    Objective-C

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

    Swift

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

    Defaults to JPEG.

    Declaration

    Objective-C

    @property (nonatomic) PSPDFDiskCacheFileFormat fileFormat;

    Swift

    var fileFormat: DiskCache.FileFormat { 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 (nonatomic) CGFloat compression;

    Swift

    var compression: 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 (nonatomic, copy, 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 (nonatomic, copy, nullable) NSData *_Nullable (^) (PSPDFRenderRequest *_Nonnull, NSData *_Nonnull) decryptionHelper;

    Swift

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