Skip to content

Commit

Permalink
Add ImagePipeline/Cache
Browse files Browse the repository at this point in the history
  • Loading branch information
kean committed Jul 1, 2022
1 parent afb7cbb commit c006aee
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 4 deletions.
26 changes: 26 additions & 0 deletions Sources/Nuke/Nuke.docc/Extensions/ImagePiplelineCache-Extension.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# ``Nuke/ImagePipeline/Cache-swift.struct``

## Topics

### Accessing Cached Images

- ``cachedImage(for:caches:)``
- ``storeCachedImage(_:for:caches:)``
- ``removeCachedImage(for:caches:)``
- ``containsCachedImage(for:caches:)``

### Accessing Cached Data

- ``cachedData(for:)``
- ``storeCachedData(_:for:)``
- ``removeCachedData(for:)``
- ``containsData(for:)``

### Removing All

- ``removeAll(caches:)``

### Cache Keys

- ``makeImageCacheKey(for:)``
- ``makeDataCacheKey(for:)``
2 changes: 1 addition & 1 deletion Sources/Nuke/Nuke.docc/Performance/Caching/cache-layers.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Nuke has three cache layers:
- ``DataCache`` – aggressive LRU **disk** cache
- [`URLCache`](https://developer.apple.com/documentation/foundation/urlcache) – HTTP **disk** cache which is part of the native [URL loading system](https://developer.apple.com/documentation/foundation/url_loading_system)

The default pipeline uses a combination of ``ImageCache`` and [`URLCache`](https://developer.apple.com/documentation/foundation/urlcache) with an increased disk size.
The default pipeline uses a combination of ``ImageCache`` and [`URLCache`](https://developer.apple.com/documentation/foundation/urlcache) with an increased disk size. Thie configuration supports HTTP [`cache-control`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control).

### Memory Cache

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,6 @@ class ImagePipelineCacheTests: XCTestCase {
// MARK: ImageRequestConvertible

func testMakeSureAllAPIsAreAvailable() {
cache[URL(string: "https://example.com/image.jpeg")!] = nil
cache[ImageRequest(url: URL(string: "https://example.com/image.jpeg")!)] = nil
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ class ImagePipelinePublisherProgressiveDecodingTests: XCTestCase {

func testImagePreviewsAreDeliveredFromMemoryCacheSynchronously() {
// GIVEN
pipeline.cache[Test.url] = ImageContainer(image: Test.image, isPreview: true)
pipeline.cache[Test.request] = ImageContainer(image: Test.image, isPreview: true)

let imagesProduced = self.expectation(description: "ImagesProduced")
// 1 preview from sync cache lookup
Expand Down
2 changes: 1 addition & 1 deletion Tests/NukeTests/ImagePrefetcherTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ final class ImagePrefetcherTests: XCTestCase {
dataLoader.isSuspended = true

// GIVEN
pipeline.cache[Test.url] = Test.container
pipeline.cache[Test.request] = Test.container

// WHEN
prefetcher.startPrefetching(with: [Test.url])
Expand Down

0 comments on commit c006aee

Please sign in to comment.