Nuke Documentation

Structure Image​Pipeline.​Configuration

public struct Configuration  

The pipeline configuration.

Member Of

ImagePipeline

ImagePipeline is the primary way to load images directly (without a UI).

Nested Types

ImagePipeline.Configuration.DataCachePolicy

Determines what images are stored in the disk cache.

Initializers

init(data​Loader:​)

public init(dataLoader: DataLoading = DataLoader())  

Instantiates a default pipeline configuration.

Parameters

data​Loader Data​Loading

DataLoader() by default.

Properties

image​Cache

public var imageCache: ImageCaching?  

Image cache used by the pipeline.

data​Loader

public var dataLoader: DataLoading

Data loader used by the pipeline.

data​Cache

public var dataCache: DataCaching? 

Data cache used by the pipeline.

make​Image​Decoder

public var makeImageDecoder: (ImageDecodingContext) -> ImageDecoding? = ImageDecoderRegistry.shared.decoder(for:) 

Default implementation uses shared ImageDecoderRegistry to create a decoder that matches the context.

make​Image​Encoder

public var makeImageEncoder: (ImageEncodingContext) -> ImageEncoding  

Returns ImageEncoders.Default() by default.

data​Loading​Queue

public var dataLoadingQueue  

Data loading queue. Default maximum concurrent task count is 6.

data​Caching​Queue

public var dataCachingQueue  

Data caching queue. Default maximum concurrent task count is 2.

image​Decoding​Queue

public var imageDecodingQueue  

Image decoding queue. Default maximum concurrent task count is 1.

image​Encoding​Queue

public var imageEncodingQueue  

Image encoding queue. Default maximum concurrent task count is 1.

image​Processing​Queue

public var imageProcessingQueue  

Image processing queue. Default maximum concurrent task count is 2.

image​Decompressing​Queue

public var imageDecompressingQueue  

Image decompressing queue. Default maximum concurrent task count is 2.

callback​Queue

public var callbackQueue = DispatchQueue.main

A queue on which all callbacks, like progress and completion callbacks are called. .main by default.

is​Decompression​Enabled

public var isDecompressionEnabled = true

Decompresses the loaded images. true by default.

Decompressing compressed image formats (such as JPEG) can significantly improve drawing performance as it allows a bitmap representation to be created in a background rather than on the main thread.

data​Cache​Policy

public var dataCachePolicy = DataCachePolicy.storeOriginalData

.storeOriginalData by default.

is​Task​Coalescing​Enabled

public var isTaskCoalescingEnabled = true

true by default. If true the pipeline avoids duplicated work when loading images. The work only gets cancelled when all the registered requests are. The pipeline also automatically manages the priority of the deduplicated work.

Let's take these two requests for example:

let url = URL(string: "http://example.com/image")
pipeline.loadImage(with: ImageRequest(url: url, processors: [
    ImageProcessors.Resize(size: CGSize(width: 44, height: 44)),
    ImageProcessors.GaussianBlur(radius: 8)
]))
pipeline.loadImage(with: ImageRequest(url: url, processors: [
    ImageProcessors.Resize(size: CGSize(width: 44, height: 44))
]))

Nuke will load the image data only once, resize the image once and apply the blur also only once. There is no duplicated work done at any stage.

is​Rate​Limiter​Enabled

public var isRateLimiterEnabled = true

true by default. If true the pipeline will rate limit requests to prevent trashing of the underlying systems (e.g. URLSession). The rate limiter only comes into play when the requests are started and cancelled at a high rate (e.g. scrolling through a collection view).

is​Progressive​Decoding​Enabled

public var isProgressiveDecodingEnabled = true

false by default. If true the pipeline will try to produce a new image each time it receives a new portion of data from data loader. The decoder used by the image loading session determines whether to produce a partial image or not. The default image decoder (ImageDecoder) supports progressive JPEG decoding.

is​Storing​Previews​InMemory​Cache

public var isStoringPreviewsInMemoryCache = true

false by default. If true, the pipeline will store all of the progressively generated previews in the memory cache. All of the previews have isPreview flag set to true.

is​Resumable​Data​Enabled

public var isResumableDataEnabled = true

If the data task is terminated (either because of a failure or a cancellation) and the image was partially loaded, the next load will resume where it left off. Supports both validators (ETag, Last-Modified). Resumable downloads are enabled by default.

is​Signpost​Logging​Enabled

public static var isSignpostLoggingEnabled = false  

false by default. If true, enables os_signpost logging for measuring performance. You can visually see all the performance metrics in os_signpost Instrument. For more information see https://developer.apple.com/documentation/os/logging and https://developer.apple.com/videos/play/wwdc2018/405/.

with​URLCache

public static var withURLCache: Configuration  

A configuration with a DataLoader with an HTTP disk cache (URLCache) with a size limit of 150 MB.

with​Data​Cache

public static var withDataCache: Configuration  

A configuration with an aggressive disk cache (DataCache) with a size limit of 150 MB. An HTTP cache (URLCache) is disabled.