{"id":16452048,"url":"https://github.com/raulriera/cacher","last_synced_at":"2025-10-14T20:35:51.544Z","repository":{"id":55471839,"uuid":"96645077","full_name":"raulriera/Cacher","owner":"raulriera","description":"Super simple caching solution for iOS, macOS, tvOS and watchOS.","archived":false,"fork":false,"pushed_at":"2022-07-29T04:03:24.000Z","size":149,"stargazers_count":171,"open_issues_count":2,"forks_count":20,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-09-27T06:06:24.343Z","etag":null,"topics":["caching","ios","macos","swift"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/raulriera.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-07-08T21:24:47.000Z","updated_at":"2025-06-30T20:31:20.000Z","dependencies_parsed_at":"2022-08-15T01:10:19.598Z","dependency_job_id":null,"html_url":"https://github.com/raulriera/Cacher","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/raulriera/Cacher","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raulriera%2FCacher","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raulriera%2FCacher/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raulriera%2FCacher/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raulriera%2FCacher/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/raulriera","download_url":"https://codeload.github.com/raulriera/Cacher/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raulriera%2FCacher/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279020905,"owners_count":26086948,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-14T02:00:06.444Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["caching","ios","macos","swift"],"created_at":"2024-10-11T10:11:10.811Z","updated_at":"2025-10-14T20:35:51.529Z","avatar_url":"https://github.com/raulriera.png","language":"Swift","readme":"[![Build Status](https://travis-ci.org/raulriera/Cacher.svg?branch=master)](https://travis-ci.org/raulriera/Cacher)\n\n\u003cimg src=\"/Resources/Icon.png\" /\u003e\n\nFor a detail information about using \"Cacher\", checkout the article [\"Caching anything in iOS\"](https://medium.com/ios-os-x-development/caching-anything-in-ios-102176e46eba).\n\n## Installation\n\n### Manual\n\nDrag and drop the `Cacher/` folder into your project.\n\n### Carthage\n\nAdd the following to your Cartfile:\n\n```ruby\ngithub \"raulriera/Cacher\"\n```\n\n### Swift Package Manager\n\nAdd this repo to your dependencies.\n\n## How to use them\n\nFor a quick TL;DR check out the sample project at `CacherDemo`. It will guide you with the simplest caching possible, persisting string values.\n\nIf you like to get your hands dirty, continue reading as we are going to go into detail about how this works.\n\n``` swift\npublic protocol Cachable {\n\tvar fileName: String { get }\n\tfunc transform() -\u003e Data\n}\n```\n\nIt all comes down to this simple protocol, that has only two requirements `fileName` which represents the unique name to store in the filesystem, and `transform` which is the `Data` representation of what you wish to import. Using the magic of Swift 4 `Codable`, we can skip the `transform` implementation and use the implicit one declared [right here](/Cacher/Cacher.swift#L110).\n\nAfter we implement conform to `Cachable` and `Codable`, anything can be stored in the filesystem using the `persist:item:completion` method.\n\nBut, let's see a more complex example\n\n```swift\nstruct CachableMovies: Cachable, Codable {\n\tlet store: String\n\tlet movies: [Movie]\n\n\tvar fileName: String {\n\t\treturn \"movies-\\(store)\"\n\t}\n\n\tinit(store: String, movies: [Movie]) {\n\t\tself.store = store\n\t\tself.movies = movies\n\t}\n}\n\nstruct Movie: Codable {\n  enum CodingKeys : String, CodingKey {\n  \t\tcase title = \"movie_title\"\n  \t\tcase description = \"movie_description\"\n  \t\tcase url = \"movie_url\"\n  }\n\n  let title: String\n  let description: String\n  let url: URL\n}\n```\n\nThe previous code is all we need to store a collection of movies into the filesystem. 🎉 Now we can simply use the `persist` method like this.\n\n```swift\nCacher(destination: .temporary).persist(item: CachableMovies(store: \"USA\", movies: myArrayOfMovies)) { url, error in\n\t// Completion handler when the process finishes\n}\n```\n\n## Created by\nRaul Riera, [@raulriera](http://twitter.com/raulriera)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fraulriera%2Fcacher","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fraulriera%2Fcacher","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fraulriera%2Fcacher/lists"}