{"id":21390855,"url":"https://github.com/zzjzz9266a/objectmappercachemanager","last_synced_at":"2025-03-16T13:20:23.793Z","repository":{"id":62449479,"uuid":"155542587","full_name":"zzjzz9266a/ObjectMapperCacheManager","owner":"zzjzz9266a","description":"A Light-Weight Tool For Cache Of ObjectMapper","archived":false,"fork":false,"pushed_at":"2018-11-17T17:26:43.000Z","size":108,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-25T20:46:34.780Z","etag":null,"topics":["cache","high-performance","light","objectmapper"],"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/zzjzz9266a.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":"2018-10-31T10:57:54.000Z","updated_at":"2024-08-30T02:01:15.000Z","dependencies_parsed_at":"2022-11-01T23:02:18.290Z","dependency_job_id":null,"html_url":"https://github.com/zzjzz9266a/ObjectMapperCacheManager","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zzjzz9266a%2FObjectMapperCacheManager","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zzjzz9266a%2FObjectMapperCacheManager/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zzjzz9266a%2FObjectMapperCacheManager/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zzjzz9266a%2FObjectMapperCacheManager/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zzjzz9266a","download_url":"https://codeload.github.com/zzjzz9266a/ObjectMapperCacheManager/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243872305,"owners_count":20361453,"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":["cache","high-performance","light","objectmapper"],"created_at":"2024-11-22T13:20:05.282Z","updated_at":"2025-03-16T13:20:23.769Z","avatar_url":"https://github.com/zzjzz9266a.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://github.com/zzjzz9266a/ObjectMapperCacheManager\"\u003e\u003cimg src=\"https://github.com/zzjzz9266a/ObjectMapperCacheManager/blob/master/logo.png\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://img.shields.io/badge/Swift-4.0-orange.svg?style=flat\"\u003e\n  \u003cimg src=\"https://img.shields.io/badge/Pod-v2.7-blue.svg?style=flat\"\u003e\n  \u003cimg src=\"https://img.shields.io/badge/Platform-iOS-4BC51D.svg?style=flat\"\u003e\n\u003c/p\u003e\n\u003c!--\u003cp align=\"center\"\u003eA Light-Weight Tool For Cache, based on \u003ca href=\"https://github.com/tristanhimmelman/ObjectMapper\"\u003eObjectMapper\u003c/a\u003e\u003c/p\u003e--\u003e\n\n[中文简介](https://github.com/zzjzz9266a/ObjectMapperCacheManager/blob/master/README_CN.md)\n\n## Installation\n### Cocoapods\n```\npod 'ObjectMapperCacheManager'\n```\n\n## Usage\nWhen store something to a device, \"key\" is the only identifier, just like `UserDefaults` in `Foundation`.\n\n``` swift\nUserDefaults.standard.setValue([\"name\": \"James\", \"age\": 16], forKey: \"User\")\n```\nBut, the difference between `UserDefaults` and `CacheManager` is the directory in sandbox:\n* `UserDefaults`: Home/Library/Preference/  \n\n* `CacheManager`: Home/Library/Caches\n\n### 1. Store key-value data\nThe data could be a dict or an array\n\n``` swift\nlet dict: [String: Any] = [\"name\": \"James\", \"age\": 16]\nCacheManager.setCache(json: dict, for: \"Json\")\n\nlet dictArray = [[String: Any]] = [dict]\nCacheManager.setCache(json: dictArray, for: \"JsonArray\")\n```\n\n### 2. Get cached key-value data\n``` swift\n// must declare the type\nif let dict: [String: Any] = CacheManager.cacheJson(for: \"Json\") as? [String: Any]{  \n  print(dict)\n}\n\nif let array: [[String: Any]] = CacheManager.cacheJson(for: \"JsonArray\") as? [String: Any]{  \n  print(array)\n}\n```\n\n### 3. Store an object or an array of ObjectMapper\nThe only requirement is that the object must conform to ObjectMapper's `Mappable` protocol.\n\n``` swift\nlet user: User = User()\nCacheManager.setCache(object: user, for: \"Object\")\n\nlet userList = [user]\nCacheManager.setCache(array: userList, for: \"ObjectArray\")\n```\n### 4. Get cached object of array\n\n``` swift\nif let user: User = CacheManager.cache(for: \"Object\") {\n    //use data\n}\n\nif let array: [User] = CacheManager.cacheArray(for: \"ObjectArray\") {\n    //use data\n}\n\n```\n\n## License\n`ObjectMapperCacheManager` is released under an MIT license. See LICENSE for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzzjzz9266a%2Fobjectmappercachemanager","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzzjzz9266a%2Fobjectmappercachemanager","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzzjzz9266a%2Fobjectmappercachemanager/lists"}