{"id":977,"url":"https://github.com/SwiftKitz/Storez","last_synced_at":"2025-08-06T13:32:00.942Z","repository":{"id":2437056,"uuid":"46546868","full_name":"SwiftKitz/Storez","owner":"SwiftKitz","description":"💾 Safe, statically-typed, store-agnostic key-value storage written in Swift!","archived":false,"fork":false,"pushed_at":"2022-05-02T19:00:52.000Z","size":112,"stargazers_count":68,"open_issues_count":1,"forks_count":8,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-07-02T22:47:15.579Z","etag":null,"topics":["cache","carthage","cocoapods","codable","ios","key-value","macos","persistence","preferences","storage","tvos","user-defaults","watchos"],"latest_commit_sha":null,"homepage":"https://swiftkitz.github.io/","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/SwiftKitz.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2015-11-20T07:35:06.000Z","updated_at":"2024-10-24T08:40:55.000Z","dependencies_parsed_at":"2022-08-08T05:15:07.924Z","dependency_job_id":null,"html_url":"https://github.com/SwiftKitz/Storez","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/SwiftKitz/Storez","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SwiftKitz%2FStorez","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SwiftKitz%2FStorez/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SwiftKitz%2FStorez/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SwiftKitz%2FStorez/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SwiftKitz","download_url":"https://codeload.github.com/SwiftKitz/Storez/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SwiftKitz%2FStorez/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269022226,"owners_count":24346278,"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-08-06T02:00:09.910Z","response_time":99,"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":["cache","carthage","cocoapods","codable","ios","key-value","macos","persistence","preferences","storage","tvos","user-defaults","watchos"],"created_at":"2024-01-05T20:15:36.114Z","updated_at":"2025-08-06T13:32:00.521Z","avatar_url":"https://github.com/SwiftKitz.png","language":"Swift","readme":"\n\u003ch1 align=\"center\"\u003e\n  Storez :floppy_disk:\n\u003ch6 align=\"center\"\u003e\n  Safe, statically-typed, store-agnostic key-value storage\n\u003c/h6\u003e\n\u003c/h1\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003cimg alt=\"Version\" src=\"https://img.shields.io/badge/version-4.1.0-blue.svg\" /\u003e\n  \u003ca alt=\"Github CI\" href=\"https://github.com/SwiftKitz/Storez/actions\"\u003e\n    \u003cimg alt=\"Version\" src=\"https://github.com/SwiftKitz/Storez/workflows/Swift/badge.svg\" /\u003e\n  \u003c/a\u003e\n  \u003cimg alt=\"Swift\" src=\"https://img.shields.io/badge/swift-5.3-orange.svg\" /\u003e\n  \u003cimg alt=\"Platforms\" src=\"https://img.shields.io/badge/platform-ios%20%7C%20osx%20%7C%20watchos%20%7C%20tvos-lightgrey.svg\" /\u003e\n\u003c/p\u003e\n\n## Highlights\n\n+ __Fully Customizable:__\u003cbr /\u003e\nCustomize the persistence store, the `KeyType` class, post-commit actions .. Make this framework yours!\n\n+ __Batteries Included__:\u003cbr /\u003e\nIn case you just want to use stuff, the framework is shipped with pre-configured basic set of classes that you can just use.\n\n+ __Portability, Check!:__\u003cbr /\u003e\nIf you're looking to share code between you app and extensions, watchkit, apple watch, you're covered! You can use the `NSUserDefaults` store, just set your shared container identifier as the suite name.\n\n**Example:**\n\n```swift\nfinal class WeatherService {\n\n  private enum Keys: Namespace {\n    static let id = \"weather-service\"\n    static let temperature = Key\u003cKeys, Double\u003e(id: \"temp\", defaultValue: 0.0)\n  }\n\n  private let store: UserDefaultsStore\n  \n  var temperature: Double {\n    return store.get(Keys.temperature)\n  }\n\n  init(store: UserDefaultsStore) {\n    self.store = store\n  }\n\n  func weatherUpdate(temperature: Double) {\n    store.set(Keys.temperature, temperature)\n  }\n}\n```\n\n## Features\n\n__Available Stores__\n\n| Store | Backend | Subspec |\n|-------|---------|---------|\n| `UserDefaultsStore` | `NSUserDefaults` | `Storez/UserDefaults` |\n| `CacheStore` | `NSCache` | `Storez/Cache` |\n\nFor all stores, simply use `pod \"Storez\"`\n\n__Type-safe, store-agnostic, nestable Key definitions__\n\n```swift\n// Entries must belong to a \"group\", for namespacing\nstruct Animals: Namespace {\n    static let id = \"animals\"\n}\n\nlet kingdom = Key\u003cAnimals, Void?\u003e(id: \"mammals\", defaultValue: nil)\nkingdom.stringValue // \"animals:mammals\"\n\n// Nesting\nstruct Cats: Namespace {\n    typealias parent = Animals\n    static let id = \"cats\"\n\n    // Namespaces also have pre and post commit hooks\n    func preCommitHook() { /* custom code */ }\n    func postCommitHook() { /* custom code */ }\n}\n\nlet cat = Key\u003cCats, Void?\u003e(id: \"lion\", defaultValue: nil)\ncat.stringValue // \"animals:cats:lion\"\n```\n\n__Initialize the store you want__\n\n```swift\n// Use UserDefaultsStore for this example\nlet store = UserDefaultsStore(suite: \"io.kitz.testing\")\nlet key = Key\u003cGlobalNamespace, Int?\u003e(id: \"key\", defaultValue: nil)\n\n// With three simple functions\nstore.set(key, value: 8)\nstore.get(key) // 8\nstore.clear() // Start fresh every time for testing\n```\n\n__Optionality is honored throughout__\n\n```swift\nlet nullable = Key\u003cGlobalNamespace, String?\u003e(id: \"nullable\", defaultValue: nil)\nstore.get(nullable)?.isEmpty   // nil\nstore.set(nullable, value: \"\")\nstore.get(nullable)?.isEmpty   // true\n\nlet nonnull = Key\u003cGlobalNamespace, String\u003e(id: \"nonnull\", defaultValue: \"!\")\nstore.get(nonnull).isEmpty  // false\nstore.set(nonnull, value: \"\")\nstore.get(nonnull).isEmpty  // true\n```\n\n__Custom objects easily supported__\n\n**NEW** Simply conform to `Codable`!\n\n_(You can still use `UserDefaultsConvirtable` if needed)_\n\n```swift\nstruct CustomObject: Codable {\n    var strings: [String]\n}\n\n// custom objects properly serialized/deserialized\nlet customObject = CustomObject(\n    strings: [\"fill\", \"in\", \"the\"]\n)\n\n// let's add a processing block this time\nlet CustomValue = Key\u003cGlobalNamespace, CustomObject?\u003e(id: \"custom\", defaultValue: nil) {\n\n    var processedValue = $0\n    processedValue?.strings.append(\"blank!\")\n    return processedValue\n}\n\nstore.set(CustomValue, value: customObject)\nstore.get(CustomValue)?.strings.joinWithSeparator(\" \") // fill in the blank!\n```\n\n__Make your own `KeyType`__\n\n```swift\n// For example, make an key that emits NSNotifications\nstruct MyKey\u003cG: Namespace, V\u003e: KeyType {\n\n    typealias NamespaceType = G\n    typealias ValueType = V\n\n    var stringValue: String\n    var defaultValue: ValueType\n\n    func didChange(oldValue: ValueType, newValue: ValueType) {\n        NSNotificationCenter.defaultCenter().postNotificationName(stringValue, object: nil)\n    }\n}\n```\n\n## Getting Started\n\n### Swift Package Manager\n\n#### You can add Storez to an Xcode project by adding it as a package dependency.\n\n- In Xcode, from the File menu, select Add Packages...\n- Enter \"https://github.com/SwiftKitz/Storez\" into the package repository URL text field\n\nDepending on how your project is structured:\n- If you have a single application target that needs access to the library, then add Storez directly to your application.\n- If you want to use this library from multiple Xcode targets, or mixing Xcode targets and SPM targets, you likely want to create a shared framework that depends on Storez and then depend on that framework in all of your targets.\n\n#### To use Storez in a Package.swift file, add this to the `dependencies:` section.\n\n```swift\n.package(url: \"https://github.com/SwiftKitz/Storez.git\", .upToNextMinor(from: \"3.0.0\")),\n```\n\n\n### CocoaPods\n\n[CocoaPods][cocoapods-link] is fully supported. You can choose which store you want to use (see above). Simply add the following line to your [Podfile][podfile-docs]:\n\n```ruby\npod 'Storez/UserDefaults'\n```\n\n## Motivation\n\nI've seen a lot of great attempts at statically-types data stores, but they all build a tightly coupled design that limits the end-developer's freedom. With this framework, you can start prototyping right away with the shipped features, then replace the persistence store and `KeyType` functionality with your heart's content __and__ keep your code the way it is!\n\n## Author\n\nMazyod ([@Mazyod](http://twitter.com/mazyod))\n\n## License\n\nStorez is released under the MIT license. See LICENSE for details.\n\n\n[carthage-link]: https://github.com/Carthage/Carthage\n[cartfile-docs]: https://github.com/Carthage/Carthage/blob/master/Documentation/Artifacts.md#cartfile\n[cocoapods-link]: https://cocoapods.org/\n[podfile-docs]: https://guides.cocoapods.org/syntax/podfile.html\n[v1.0.0-link]: https://github.com/SwiftKitz/Storez/releases/tag/v1.0.0\n","funding_links":[],"categories":["Database","Libs","Data Management [🔝](#readme)"],"sub_categories":["Getting Started","Data Management","Other free courses","Linter"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSwiftKitz%2FStorez","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FSwiftKitz%2FStorez","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSwiftKitz%2FStorez/lists"}