{"id":21637865,"url":"https://github.com/bbc6bae9/cachekit","last_synced_at":"2025-12-24T11:18:47.919Z","repository":{"id":223624827,"uuid":"761065548","full_name":"BBC6BAE9/CacheKit","owner":"BBC6BAE9","description":"Swift memory \u0026 disk cache","archived":false,"fork":false,"pushed_at":"2025-09-03T11:52:11.000Z","size":405,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-14T03:27:00.330Z","etag":null,"topics":["apple","ios","ipados","macos","swift","swiftui","visionos","watchos"],"latest_commit_sha":null,"homepage":"https://bbc6bae9.github.io/cachekit/documentation/cachekit/","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/BBC6BAE9.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-02-21T07:08:12.000Z","updated_at":"2025-09-03T11:52:15.000Z","dependencies_parsed_at":"2024-02-21T12:26:18.310Z","dependency_job_id":"89106cc0-4c23-43ef-92fd-cf61e06c0dfa","html_url":"https://github.com/BBC6BAE9/CacheKit","commit_stats":null,"previous_names":["repo-spm/cache","spm-market/cache","bbc6bae9/cachekit"],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/BBC6BAE9/CacheKit","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BBC6BAE9%2FCacheKit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BBC6BAE9%2FCacheKit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BBC6BAE9%2FCacheKit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BBC6BAE9%2FCacheKit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BBC6BAE9","download_url":"https://codeload.github.com/BBC6BAE9/CacheKit/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BBC6BAE9%2FCacheKit/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279017766,"owners_count":26086144,"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":["apple","ios","ipados","macos","swift","swiftui","visionos","watchos"],"created_at":"2024-11-25T04:07:22.711Z","updated_at":"2025-12-24T11:18:47.914Z","avatar_url":"https://github.com/BBC6BAE9.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 📦 CacheKit \n\nCache is a lightweight thread safe disk caching tool for Apple platform, commonly used to store data returned from network requests.\n\n## Quick Start\n\n1、Init cache\n\n```Swift\nimport CacheKit\n\nlet cache = DiskCache\u003c[YOUR_CODABLE_MODEL]\u003e(filename:\"YOUR_FILE_NAME\", expirationInterval: 30 * 24 * 60 * 60)\n```\n\n2、Write cache to disk\n\n```swift\ncache.setValue(channels, forKey: keyString)\ntry? await cache.saveToDisk()\n\n```\n\n3、Load cache from disk\n\n```Swift\ncache.loadFromDisk()\n```\n\n4、Remove cache from disk\n\n```swift\ncache.removeValue(forKey: keyString)\ntry? await cache.saveToDisk()\n\n```\n\n5、More info\n\n[https://bbc6bae9.github.io/cachekit/](https://bbc6bae9.github.io/CacheKit/documentation/cachekit/)\n\n## Class Diagram\n\n```mermaid\nclassDiagram\n    class Cache~V~ {\n        \u003c\u003cprotocol\u003e\u003e\n        +TimeInterval expirationInterval\n        +setValue(V?, forKey: String)\n        +value(forKey: String) V?\n        +removeValue(forKey: String)\n        +removeAllValues()\n    }\n\n    class NSCacheType~V~ {\n        \u003c\u003cprotocol\u003e\u003e\n        +NSCache~NSString, CacheEntry~V~~ cache\n        +KeysTracker~V~ keysTracker\n        +setValue(V?, forKey: String)\n        +value(forKey: String) V?\n        +removeValue(forKey: String)\n        +removeAllValues()\n        #entry(forKey: String) CacheEntry~V~?\n        #insert(CacheEntry~V~)\n    }\n\n    class InMemoryCache~V~ {\n        +init(expirationInterval: TimeInterval)\n        +TimeInterval expirationInterval\n        -NSCache~NSString, CacheEntry~V~~ cache\n        -KeysTracker~V~ keysTracker\n    }\n\n    class DiskCache~V~ {\n        +init(filename: String, expirationInterval: TimeInterval)\n        +String filename\n        +TimeInterval expirationInterval\n        +saveToDisk() throws\n        +loadFromDisk() throws\n        -NSCache~NSString, CacheEntry~V~~ cache\n        -KeysTracker~V~ keysTracker\n        -URL saveLocationURL\n    }\n\n    class CacheEntry~V~ {\n        +init(key: String, value: V, expiredTimestamp: Date)\n        +String key\n        +V value\n        +Date expiredTimestamp\n        +isCacheExpired(after: Date) Bool\n    }\n\n    class KeysTracker~V~ {\n        +Set~String~ keys\n        +cache(_:willEvictObject:) void\n    }\n\n    class NSCache {\n        \u003c\u003cFoundation\u003e\u003e\n        +setObject(AnyObject?, forKey: AnyObject)\n        +object(forKey: AnyObject) AnyObject?\n        +removeObject(forKey: AnyObject)\n        +removeAllObjects()\n    }\n\n    Cache \u003c|.. NSCacheType\n    NSCacheType \u003c|.. InMemoryCache\n    NSCacheType \u003c|.. DiskCache\n    NSCacheType o-- CacheEntry\n    NSCacheType o-- KeysTracker\n    NSCacheType o-- NSCache\n    KeysTracker --|\u003e NSCacheDelegate\n    CacheEntry ..|\u003e Codable\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbbc6bae9%2Fcachekit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbbc6bae9%2Fcachekit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbbc6bae9%2Fcachekit/lists"}