{"id":19742516,"url":"https://github.com/maximkrouk/storage","last_synced_at":"2025-10-30T11:42:13.110Z","repository":{"id":56906146,"uuid":"216522966","full_name":"maximkrouk/Storage","owner":"maximkrouk","description":"Lightweight framework for storing data (beta)","archived":false,"fork":false,"pushed_at":"2019-10-21T10:44:16.000Z","size":81,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-11T07:35:50.079Z","etag":null,"topics":["cache","data","keychain","memmory","storage","swift","swift5-1","userdefaults"],"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/maximkrouk.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":"2019-10-21T08:59:46.000Z","updated_at":"2024-12-12T10:46:15.000Z","dependencies_parsed_at":"2022-08-21T02:20:59.549Z","dependency_job_id":null,"html_url":"https://github.com/maximkrouk/Storage","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maximkrouk%2FStorage","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maximkrouk%2FStorage/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maximkrouk%2FStorage/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maximkrouk%2FStorage/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/maximkrouk","download_url":"https://codeload.github.com/maximkrouk/Storage/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241072605,"owners_count":19904806,"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","data","keychain","memmory","storage","swift","swift5-1","userdefaults"],"created_at":"2024-11-12T01:32:01.090Z","updated_at":"2025-10-30T11:42:08.074Z","avatar_url":"https://github.com/maximkrouk.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Storage\n\nEvery type of storage:\n\n- Has the same interface.\n- Extendable.\n- Thread safe.\n\n#### Interface:\n\nAny storage provided via managers is accessible as key-value pairs. You may use strings, but you'll be getting warnings, because I deprecated this approach. Natively the framework advices you to use string based enums.\n\nIn exaples I'll be using this:\n\n```swift\nenum Auth: String {\n    case username // .rawValue == \"username\"\n    case isAdmin  // .rawValue == \"isAdmin\"\n}\n```\n\nAvalible **Managers:**\n\n- `Keychain`\n\n  _Shortcut: KC_\n\n- `UserDefaults`\n\n  _Shortcut: UD_\n\n- `Cache` [temporary / persistent]\n\n  _Shortcut: CH_\n\nYou can easily extend Avalible managers with your own by writinfg an implementation and subscribing your managers to a `StorageManagerProtocol`\n\nYou should access any storage via providers. You may use them as static or singleton's properties.\n\n- `[Manager].[Provider]`\n\nOut-of-the-box **Providers:**\n\n- `.data`\n- `.bool`\n- `.string`\n\n**Providers** allow you to access storage:\n\n- Via subscripts:\n  - `provider[key]`\n- Via methods:\n  - `provider.get(for: key)`\n  - `provider.set(value, for: key)`\n- Via deprecated subscripts and methods:\n  - `provider[stringKey]`\n  - `provider.get(forKey: stringKey)`\n  - `provider.set(value, forKey: stringKey)`\n\nFor convenience it would be nice to extend framework's `Storage.Provider` with your custom adapter subscripts:\n\n```swift\nextension Storage.Provider {\n    subscript(key: Auth) -\u003e Value? {    // Value is a Provider's assosiated type.\n        get { get(for: key) }           // Just pass key to build-in getter,\n        set { set(newValue, for: key) } // or key-value to build in setter.\n    }\n}\n```\n\nThis will allow you to access storage not just like this:\n\n- `Storage.[Manager].[Provider][Auth.username]`\n\nbut also like this:\n\n- `Storage.[Manager].[Provider][.username]`\n\n#### Keychain as an example:\n\n- `Storage.Keychain.data.set(nil, forKey: \"deletedItem\")`\n- `Storage.Keychain.data.get(forKey: \"deletedItem\") // nil`\n- `Storage.Keychain.data[\"StringKeys\"] = \"Sucks c:\".data(using: .utf8)`\n- `Storage.Keychain.default.string[.username] = \"Root\"`\n- `Storage.Keychain.default.bool[.isAdmin] = true`\n- `Storage.KC.bool[.isAdmin] // true`","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaximkrouk%2Fstorage","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmaximkrouk%2Fstorage","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaximkrouk%2Fstorage/lists"}