<commit_before>// The MIT License (MIT)
//
// Copyright (c) 2015-2021 <NAME> (github.com/kean).

import Foundation

public extension ImagePipeline {
    /// Thread-safe.
    struct Cache {
        let pipeline: ImagePipeline

        /// Returns processed image from the memory cache for the given request.
        public subscript(request: ImageRequestConvertible) -> PlatformImage? {
            get {
                cachedImageFromMemoryCache(for: request.asImageRequest())?.image
            }
            set {
                fatalError("Not implemented")
            }
        }

        // MARK: Cached Images

        /// Returns a cached image from the memory cache. Add `.disk` as a source
        /// to also check the disk cache.
        ///
        /// - note: Respects request options such as `cachePolicy`.
        ///
        /// - parameter request: The request. Make sure to remove the processors
        /// if you want to retrieve an original image (if it's stored).
        /// - parameter sources: `[.memory]`, by default.
        public func cachedImage(for request: ImageRequest, sources: Set<ImageCacheType> = [.memory]) -> ImageContainer? {
            if sources.contains(.memory) {
                if let image = cachedImageFromMemoryCache(for: request) {
                    return image
                }
            }
            if sources.contains(.disk) {
                if let data = cachedData(for: request),
                   let image = decodeImageData(data, for: request) {
                    return image
                }<commit_msg>Implement another part of Cache subscript<commit_after>// The MIT License (MIT)
//
// Copyright (c) 2015-2021 <NAME> (github.com/kean).

import Foundation

public extension ImagePipeline {
    /// Thread-safe.
    struct Cache {
        let pipeline: ImagePipeline

        /// Returns processed image from the memory cache for the given request.
        public subscript(request: ImageRequestConvertible) -> PlatformImage? {
            get {
                cachedImageFromMemoryCache(for: request.asImageRequest())?.image
            }
            set {
                if let image = newValue {
                    storeCachedImageInMemoryCache(ImageContainer(image: image), for: request.asImageRequest())
                } else {
                    fatalError("Not implemented")
                }
            }
        }

        // MARK: Cached Images

        /// Returns a cached image from the memory cache. Add `.disk` as a source
        /// to also check the disk cache.
        ///
        /// - note: Respects request options such as `cachePolicy`.
        ///
        /// - parameter request: The request. Make sure to remove the processors
        /// if you want to retrieve an original image (if it's stored).
        /// - parameter sources: `[.memory]`, by default.
        public func cachedImage(for request: ImageRequest, sources: Set<ImageCacheType> = [.memory]) -> ImageContainer? {
            if sources.contains(.memory) {
                if let image = cachedImageFromMemoryCache(for: request) {
                    return image
                }
            }
            if sources.contains(.disk) {
                if let data = cachedData(for: request),
                   let image = decodeImageData(data, for: request) {
                    return image
                }
{'fraction_non_alphanumeric': 0.09539279385705847, 'fraction_numerical': 0.004725339633786178, 'mean_word_length': 1.6399064692127825, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4894453', 'n_tokens_mistral': 835, 'n_tokens_neox': 786, 'n_words': 272}