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).
-
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
-
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 PSPDFKitGlobal *)settings;
Swift
init(cacheDirectory: String, fileFormat: DiskCache.FileFormat, settings: PSPDFKitGlobal)
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 (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 via calling
NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES)
. As of iOS 12.2, the value is App Sandbox/Libraries/Caches. Example: “/var/mobile/Containers/Data/Application/A6EB87DC-83D8-43B7-A8F1-E7BFF92A40A3/Library/Caches”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 }