<commit_before>![Haneke](https://raw.githubusercontent.com/Haneke/HanekeSwift/master/Assets/github-header.png)

[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)

Haneke is a lightweight *generic* cache for iOS written in Swift 1.2. It's designed to be super-simple to use. Here's how you would initalize a JSON cache and fetch objects from a url:

```swift
let cache = Cache<JSON>(name: "github")
let URL = NSURL(string: "https://api.github.com/users/haneke")!
    
cache.fetch(URL: URL).onSuccess { JSON in
   println(JSON.dictionary?["bio"])
}
```

Haneke provides a memory and LRU disk cache for `UIImage`, `NSData`, `JSON`, `String` or any other type that can be read or written as data.

Particularly, Haneke excels at working with images. It includes a zero-config image cache with automatic resizing. Everything is done in background, allowing for fast, responsive scrolling. Asking Haneke to load, resize, cache and display an *appropriately sized image* is as simple as:

```swift
imageView.hnk_setImageFromURL(url)
```

_Really._

## Features

* Generic cache with out-of-the-box support for `UIImage`, `NSData`, `JSON` and `String`
* First-level memory cache using `NSCache`
* Second-level LRU disk cache using the file system
* Asynchronous [fetching](#fetchers) of original values from network or disk
* All disk access is performed in background
* Thread-safe
* Automatic cache eviction on memory warnings or disk capacity reached
* Comprehensive unit tests
* Extensible by defining [custom formats](#formats), supporting [additional types](#supporting-additional-types) or implementing [custom fetchers](#custom-fetchers)

For images:

* Zero-config `UIImageView` and `UIButton` extensions to use the cache, optimized for `UITableView` and `UICollectionView` cell reuse
* Background image resizing and decompression

## Installation

Using [CocoaPods](http://cocoapods.org/):

```ruby
use_frameworks!
pod 'Haneke', :git => 'https://github.com/Haneke/HanekeSwift.git'
```

Using [Carthage](https://github.com/Carthage/Carthage):

```
github "Haneke/HanekeSwift"
```<commit_msg>Update Cocoapods installation instructions<commit_after>![Haneke](https://raw.githubusercontent.com/Haneke/HanekeSwift/master/Assets/github-header.png)

[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)

Haneke is a lightweight *generic* cache for iOS written in Swift 1.2. It's designed to be super-simple to use. Here's how you would initalize a JSON cache and fetch objects from a url:

```swift
let cache = Cache<JSON>(name: "github")
let URL = NSURL(string: "https://api.github.com/users/haneke")!
    
cache.fetch(URL: URL).onSuccess { JSON in
   println(JSON.dictionary?["bio"])
}
```

Haneke provides a memory and LRU disk cache for `UIImage`, `NSData`, `JSON`, `String` or any other type that can be read or written as data.

Particularly, Haneke excels at working with images. It includes a zero-config image cache with automatic resizing. Everything is done in background, allowing for fast, responsive scrolling. Asking Haneke to load, resize, cache and display an *appropriately sized image* is as simple as:

```swift
imageView.hnk_setImageFromURL(url)
```

_Really._

## Features

* Generic cache with out-of-the-box support for `UIImage`, `NSData`, `JSON` and `String`
* First-level memory cache using `NSCache`
* Second-level LRU disk cache using the file system
* Asynchronous [fetching](#fetchers) of original values from network or disk
* All disk access is performed in background
* Thread-safe
* Automatic cache eviction on memory warnings or disk capacity reached
* Comprehensive unit tests
* Extensible by defining [custom formats](#formats), supporting [additional types](#supporting-additional-types) or implementing [custom fetchers](#custom-fetchers)

For images:

* Zero-config `UIImageView` and `UIButton` extensions to use the cache, optimized for `UITableView` and `UICollectionView` cell reuse
* Background image resizing and decompression

## Installation

Using [CocoaPods](http://cocoapods.org/):

```ruby
use_frameworks!
pod 'HanekeSwift'
```

Using [Carthage](https://github.com/Carthage/Carthage):

```
github "Haneke/HanekeSwift"
```
{'fraction_non_alphanumeric': 0.11372549019607843, 'fraction_numerical': 0.002306805074971165, 'mean_word_length': 5.423703703703704, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 6, 'https://': 11, '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': '157166', 'n_tokens_mistral': 1388, 'n_tokens_neox': 1292, 'n_words': 447}