         })
     }
     
+    // HACK: Ideally Cache shouldn't treat images differently but I can't think of any other way of doing this that doesn't complicate the API for other types.
+    private func decompressedImageIfNeeded(value : T) -> T {
+        if let image = value as? UIImage {
+            let decompressedImage = image.hnk_decompressedImage() as? T
+            return decompressedImage!
+        }
+        return value
+    }
+    
 }

    private func fetchFromDiskCache(diskCache : DiskCache, key : String, memoryCache : NSCache,  success doSuccess : (T) -> (), failure doFailure : ((NSError?) -> ())?) {
        diskCache.fetchData(key, success: { data in
            dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), {
                let result = T.convertFromData(data)
                // TODO: Decompress image
                // let decompressedImage = image.hnk_decompressedImage()
                if let result = result {
                    dispatch_async(dispatch_get_main_queue(), {
                        doSuccess(result)
                        let wrapper = ObjectWrapper(value: result)
                        memoryCache.setObject(wrapper, forKey: key)
                    })
                }

//  Copyright (c) 2014 Haneke. All rights reserved.
//

import UIKit

// Used to add T to NSCache
