{"id":20580828,"url":"https://github.com/soffes/cache","last_synced_at":"2025-06-22T01:34:21.761Z","repository":{"id":48517357,"uuid":"58681577","full_name":"soffes/Cache","owner":"soffes","description":"Swift caching library","archived":false,"fork":false,"pushed_at":"2020-06-03T17:05:04.000Z","size":35,"stargazers_count":212,"open_issues_count":1,"forks_count":17,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-04-08T08:13:24.959Z","etag":null,"topics":["carthage","ios","macos","swift","tvos","watchos"],"latest_commit_sha":null,"homepage":null,"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/soffes.png","metadata":{"files":{"readme":"Readme.markdown","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":"2016-05-12T22:30:28.000Z","updated_at":"2025-01-30T16:48:02.000Z","dependencies_parsed_at":"2022-08-25T16:12:19.739Z","dependency_job_id":null,"html_url":"https://github.com/soffes/Cache","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/soffes/Cache","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soffes%2FCache","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soffes%2FCache/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soffes%2FCache/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soffes%2FCache/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/soffes","download_url":"https://codeload.github.com/soffes/Cache/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soffes%2FCache/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261220380,"owners_count":23126740,"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","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":["carthage","ios","macos","swift","tvos","watchos"],"created_at":"2024-11-16T06:25:40.299Z","updated_at":"2025-06-22T01:34:16.735Z","avatar_url":"https://github.com/soffes.png","language":"Swift","readme":"# Cache\n\n[![Version](https://img.shields.io/github/release/soffes/Cache.svg)](https://github.com/soffes/Cache/releases)\n[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)\n\nA generic caching library for Swift. Cache depends on Foundation.\n\nThis is still very much a work in progress.\n\n\n## Usage\n\nCache provides a simple `Cache` protocol:\n\n```swift\nprotocol Cache {\n  associatedtype Element\n\n  func get(key key: String, completion: (Element? -\u003e Void))\n  func set(key key: String, value: Element, completion: (() -\u003e Void)?)\n  func remove(key key: String, completion: (() -\u003e Void)?)\n  func removeAll(completion completion: (() -\u003e Void)?)\n}\n```\n\nThere are two (well actually three, but we'll get there) provided caches:\n\n* `MemoryCache` — Backed by an `NSCache`\n* `DiskCache` — Backed by files on disk using `NSFileManager`\n\nUsing both of these is exactly the same interface.\n\n## MultiCache\n\nThere is a third cache provided called `MultiCache`. This combines caches.\n\n```swift\nlet cache = MultiCache(caches: [memoryCache, diskCache])\ncache.set(key: \"foo\", value: \"bar\")\n```\n\nThis will write to all caches in parallel. When accessing the multi cache, it will go in order. In this example, it will try the memory cache and if there's a miss it will try the disk cache. If it were to find it in the disk cache, it will write it to all previous caches for faster future reads.\n\n\n## Thanks\n\nThanks to [Caleb Davenport](https://twitter.com/calebd) for unintentionally inspiring this and lots of help along the way.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoffes%2Fcache","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsoffes%2Fcache","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoffes%2Fcache/lists"}