{"primaryContentSections":[{"kind":"content","content":[{"anchor":"Overview","level":2,"type":"heading","text":"Overview"},{"type":"paragraph","inlineContent":[{"type":"text","text":"Bodega is an actor-based library that started as a simple cache based on reading and writing files to\/from disk with an incredibly simple API. The "},{"type":"reference","isActive":true,"identifier":"doc:\/\/Bodega\/documentation\/Bodega\/DiskStorageEngine"},{"type":"text","text":" still provides that functionality, but Bodega has also blossomed into much more, offering a form of infrastructure that any app’s data can use."}]},{"type":"paragraph","inlineContent":[{"type":"text","text":"Bodega’s "},{"type":"reference","isActive":true,"identifier":"doc:\/\/Bodega\/documentation\/Bodega\/StorageEngine"},{"type":"text","text":" is at the heart of what’s possible. Conforming any database, persistence layer, or even an API server, to the "},{"type":"reference","isActive":true,"identifier":"doc:\/\/Bodega\/documentation\/Bodega\/StorageEngine"},{"type":"text","text":" protocol automatically provides an incredibly simple data layer for your app thanks to Bodega’s "},{"type":"reference","isActive":true,"identifier":"doc:\/\/Bodega\/documentation\/Bodega\/ObjectStorage"},{"type":"text","text":". Rather than thinking about "},{"type":"codeVoice","code":"Data"},{"type":"text","text":" and databases developers interact with their app’s Swift types no matter what those may be, have a unified API, and concurrency handled out of the box."}]},{"type":"paragraph","inlineContent":[{"type":"text","text":"Bodega provides two kinds of storage primitives for you, "},{"type":"reference","isActive":true,"identifier":"doc:\/\/Bodega\/documentation\/Bodega\/StorageEngine"},{"type":"text","text":" and "},{"type":"reference","isActive":true,"identifier":"doc:\/\/Bodega\/documentation\/Bodega\/ObjectStorage"},{"type":"text","text":". The "},{"type":"reference","isActive":true,"identifier":"doc:\/\/Bodega\/documentation\/Bodega\/StorageEngine"},{"type":"text","text":" lets you write "},{"type":"codeVoice","code":"Data"},{"type":"text","text":" to your data storage, whether it’s files on disk, SQLite, or your own database. An "},{"type":"reference","isActive":true,"identifier":"doc:\/\/Bodega\/documentation\/Bodega\/ObjectStorage"},{"type":"text","text":" offers a unified layer over "},{"type":"reference","isActive":true,"identifier":"doc:\/\/Bodega\/documentation\/Bodega\/StorageEngine"},{"type":"text","text":"s, providing a single API for saving "},{"type":"codeVoice","code":"Codable"},{"type":"text","text":" objects to the "},{"type":"reference","isActive":true,"identifier":"doc:\/\/Bodega\/documentation\/Bodega\/StorageEngine"},{"type":"text","text":" of your choice. "},{"type":"reference","isActive":true,"identifier":"doc:\/\/Bodega\/documentation\/Bodega"},{"type":"text","text":" has a "},{"type":"reference","isActive":true,"identifier":"doc:\/\/Bodega\/documentation\/Bodega\/DiskStorageEngine"},{"type":"text","text":" and "},{"type":"reference","isActive":true,"identifier":"doc:\/\/Bodega\/documentation\/Bodega\/SQLiteStorageEngine"},{"type":"text","text":" built in, or you can even build a "},{"type":"reference","isActive":true,"identifier":"doc:\/\/Bodega\/documentation\/Bodega\/StorageEngine"},{"type":"text","text":" based on your app’s persistencey layer, database, or API server if you want a simple way to interface with your API. Composing storage engines allows you to create complex data pipelines, for example imagine querying the keychain for an API token, hitting your API, and saving the resulting items into a database, all with one API call. The possibilities are endless."}]},{"anchor":"Getting-Started","level":2,"type":"heading","text":"Getting Started"},{"type":"paragraph","inlineContent":[{"type":"text","text":"There are numerous ways to get started with Bodega depending on how you prefer to learn."}]},{"type":"paragraph","inlineContent":[{"type":"text","text":"You can explore using the built-in "},{"type":"reference","isActive":true,"identifier":"doc:\/\/Bodega\/documentation\/Bodega\/SQLiteStorageEngine"},{"type":"text","text":" to see how to build an image cache in only a few lines of code."}]},{"type":"unorderedList","items":[{"content":[{"type":"paragraph","inlineContent":[{"type":"reference","isActive":true,"identifier":"doc:\/\/Bodega\/documentation\/Bodega\/Building-An-Image-Cache"}]}]}]},{"type":"paragraph","inlineContent":[{"type":"text","text":"The built-in "},{"type":"reference","isActive":true,"identifier":"doc:\/\/Bodega\/documentation\/Bodega\/DiskStorageEngine"},{"type":"text","text":" and "},{"type":"reference","isActive":true,"identifier":"doc:\/\/Bodega\/documentation\/Bodega\/SQLiteStorageEngine"},{"type":"text","text":" should be more than enough to handle most of the tasks iOS and macOS developers perform. It’s still good to know the tradeoffs, or even when you should consider building your own "},{"type":"reference","isActive":true,"identifier":"doc:\/\/Bodega\/documentation\/Bodega\/StorageEngine"},{"type":"text","text":". If you want to build a "},{"type":"reference","isActive":true,"identifier":"doc:\/\/Bodega\/documentation\/Bodega\/StorageEngine"},{"type":"text","text":" for Core Data, the keychain, or your own custom API server, it’ll be wortwhile to explore how the "},{"type":"reference","isActive":true,"identifier":"doc:\/\/Bodega\/documentation\/Bodega\/StorageEngine"},{"type":"text","text":" works."}]},{"type":"unorderedList","items":[{"content":[{"type":"paragraph","inlineContent":[{"type":"reference","isActive":true,"identifier":"doc:\/\/Bodega\/documentation\/Bodega\/Using-StorageEngines"}]}]}]},{"type":"paragraph","inlineContent":[{"type":"text","text":"Most of the time though you’ll find yourself working with Swift models rather than "},{"type":"codeVoice","code":"Data"},{"type":"text","text":" directly, a task "},{"type":"reference","isActive":true,"identifier":"doc:\/\/Bodega\/documentation\/Bodega\/ObjectStorage"},{"type":"text","text":" is perfect for. Learn how to setup "},{"type":"reference","isActive":true,"identifier":"doc:\/\/Bodega\/documentation\/Bodega\/ObjectStorage"},{"type":"text","text":", and you’ll be storing Swift types in no time."}]},{"type":"unorderedList","items":[{"content":[{"type":"paragraph","inlineContent":[{"type":"reference","isActive":true,"identifier":"doc:\/\/Bodega\/documentation\/Bodega\/Using-ObjectStorage"}]}]}]},{"type":"paragraph","inlineContent":[{"type":"text","text":"Bodega is fully usable and useful on its own, but it’s also the foundation of "},{"type":"reference","isActive":true,"identifier":"https:\/\/github.com\/mergesort\/Boutique"},{"type":"text","text":". If you’re looking to build a complete SwiftUI, UIKit, or AppKit app around these concepts then Boutique is a perfect fit for that problem. The library allows you to build an offline-ready realtime updating app in only a few lines of code."}]},{"type":"unorderedList","items":[{"content":[{"type":"paragraph","inlineContent":[{"type":"reference","isActive":true,"identifier":"https:\/\/build.ms\/boutique\/docs"}]}]}]}]}],"schemaVersion":{"major":0,"minor":2,"patch":0},"sections":[],"variants":[{"paths":["\/documentation\/bodega"],"traits":[{"interfaceLanguage":"swift"}]}],"identifier":{"url":"doc:\/\/Bodega\/documentation\/Bodega","interfaceLanguage":"swift"},"abstract":[{"type":"text","text":"A simple store all your basic needs, and also so much more. 🐱"}],"kind":"symbol","metadata":{"roleHeading":"Framework","externalID":"Bodega","title":"Bodega","symbolKind":"module","role":"collection","modules":[{"name":"Bodega"}]},"hierarchy":{"paths":[[]]},"topicSections":[{"title":"Fundamentals","identifiers":["doc:\/\/Bodega\/documentation\/Bodega\/Using-StorageEngines","doc:\/\/Bodega\/documentation\/Bodega\/Using-ObjectStorage"]},{"title":"Walkthroughs","identifiers":["doc:\/\/Bodega\/documentation\/Bodega\/Building-An-Image-Cache"]},{"title":"Classes","identifiers":["doc:\/\/Bodega\/documentation\/Bodega\/DiskStorageEngine","doc:\/\/Bodega\/documentation\/Bodega\/ObjectStorage","doc:\/\/Bodega\/documentation\/Bodega\/SQLiteStorageEngine"]},{"title":"Protocols","identifiers":["doc:\/\/Bodega\/documentation\/Bodega\/StorageEngine"]},{"title":"Structures","identifiers":["doc:\/\/Bodega\/documentation\/Bodega\/CacheKey"]}],"references":{"doc://Bodega/documentation/Bodega/Using-ObjectStorage":{"role":"article","title":"Using ObjectStorage","abstract":[{"type":"reference","isActive":true,"identifier":"doc:\/\/Bodega\/documentation\/Bodega\/ObjectStorage"},{"type":"text","text":" serves as unified layer over "},{"type":"reference","isActive":true,"identifier":"doc:\/\/Bodega\/documentation\/Bodega\/StorageEngine"},{"type":"text","text":", allowing you to work with type-safe Swift models rather than "},{"type":"codeVoice","code":"Data"},{"type":"text","text":"."}],"identifier":"doc:\/\/Bodega\/documentation\/Bodega\/Using-ObjectStorage","kind":"article","type":"topic","url":"\/documentation\/bodega\/using-objectstorage"},"doc://Bodega/documentation/Bodega/Building-An-Image-Cache":{"role":"article","title":"Building An Image Cache","abstract":[{"type":"text","text":"Bodega takes data management off your plate, making once complex problems like building an image cache much simpler."}],"identifier":"doc:\/\/Bodega\/documentation\/Bodega\/Building-An-Image-Cache","kind":"article","type":"topic","url":"\/documentation\/bodega\/building-an-image-cache"},"https://github.com/mergesort/Boutique":{"title":"Boutique","titleInlineContent":[{"type":"text","text":"Boutique"}],"type":"link","identifier":"https:\/\/github.com\/mergesort\/Boutique","url":"https:\/\/github.com\/mergesort\/Boutique"},"https://build.ms/boutique/docs":{"title":"Boutique Documentation","titleInlineContent":[{"type":"text","text":"Boutique Documentation"}],"type":"link","identifier":"https:\/\/build.ms\/boutique\/docs","url":"https:\/\/build.ms\/boutique\/docs"},"doc://Bodega/documentation/Bodega/Using-StorageEngines":{"role":"article","title":"Using StorageEngines","abstract":[{"type":"text","text":"The "},{"type":"reference","isActive":true,"identifier":"doc:\/\/Bodega\/documentation\/Bodega\/StorageEngine"},{"type":"text","text":" is at the heart of what makes Bodega, Bodega."}],"identifier":"doc:\/\/Bodega\/documentation\/Bodega\/Using-StorageEngines","kind":"article","type":"topic","url":"\/documentation\/bodega\/using-storageengines"},"doc://Bodega/documentation/Bodega/StorageEngine":{"role":"symbol","title":"StorageEngine","fragments":[{"kind":"keyword","text":"protocol"},{"kind":"text","text":" "},{"kind":"identifier","text":"StorageEngine"}],"abstract":[{"type":"text","text":"A "},{"type":"reference","isActive":true,"identifier":"doc:\/\/Bodega\/documentation\/Bodega\/StorageEngine"},{"type":"text","text":" represents a data storage mechanism for saving and persisting data."}],"identifier":"doc:\/\/Bodega\/documentation\/Bodega\/StorageEngine","kind":"symbol","type":"topic","navigatorTitle":[{"kind":"identifier","text":"StorageEngine"}],"url":"\/documentation\/bodega\/storageengine"},"doc://Bodega/documentation/Bodega/DiskStorageEngine":{"role":"symbol","title":"DiskStorageEngine","fragments":[{"kind":"keyword","text":"class"},{"kind":"text","text":" "},{"kind":"identifier","text":"DiskStorageEngine"}],"abstract":[{"type":"text","text":"A "},{"type":"reference","isActive":true,"identifier":"doc:\/\/Bodega\/documentation\/Bodega\/StorageEngine"},{"type":"text","text":" based on saving items to the file system."}],"identifier":"doc:\/\/Bodega\/documentation\/Bodega\/DiskStorageEngine","kind":"symbol","type":"topic","navigatorTitle":[{"kind":"identifier","text":"DiskStorageEngine"}],"url":"\/documentation\/bodega\/diskstorageengine"},"doc://Bodega/documentation/Bodega/ObjectStorage":{"role":"symbol","title":"ObjectStorage","fragments":[{"kind":"keyword","text":"class"},{"kind":"text","text":" "},{"kind":"identifier","text":"ObjectStorage"}],"abstract":[{"type":"text","text":"A unified layer over a "},{"type":"reference","isActive":true,"identifier":"doc:\/\/Bodega\/documentation\/Bodega\/StorageEngine"},{"type":"text","text":" primitives, allowing you to read, write, and save Swift objects."}],"identifier":"doc:\/\/Bodega\/documentation\/Bodega\/ObjectStorage","kind":"symbol","type":"topic","navigatorTitle":[{"kind":"identifier","text":"ObjectStorage"}],"url":"\/documentation\/bodega\/objectstorage"},"doc://Bodega/documentation/Bodega":{"role":"collection","title":"Bodega","abstract":[{"type":"text","text":"A simple store all your basic needs, and also so much more. 🐱"}],"identifier":"doc:\/\/Bodega\/documentation\/Bodega","kind":"symbol","type":"topic","url":"\/documentation\/bodega"},"doc://Bodega/documentation/Bodega/CacheKey":{"role":"symbol","title":"CacheKey","fragments":[{"kind":"keyword","text":"struct"},{"kind":"text","text":" "},{"kind":"identifier","text":"CacheKey"}],"abstract":[{"type":"reference","isActive":true,"identifier":"doc:\/\/Bodega\/documentation\/Bodega\/CacheKey"},{"type":"text","text":" is a type meant to provide a stable storage key."},{"type":"text","text":" "},{"type":"text","text":"If initialized from a URL the "},{"type":"reference","isActive":true,"identifier":"doc:\/\/Bodega\/documentation\/Bodega\/CacheKey"},{"type":"text","text":" value will generate"},{"type":"text","text":" "},{"type":"text","text":"a consistent UUID-formatted MD5 version of the URL string as the key"},{"type":"text","text":" "},{"type":"text","text":"to ensure it is file system safe."}],"identifier":"doc:\/\/Bodega\/documentation\/Bodega\/CacheKey","kind":"symbol","type":"topic","navigatorTitle":[{"kind":"identifier","text":"CacheKey"}],"url":"\/documentation\/bodega\/cachekey"},"doc://Bodega/documentation/Bodega/SQLiteStorageEngine":{"role":"symbol","title":"SQLiteStorageEngine","fragments":[{"kind":"keyword","text":"class"},{"kind":"text","text":" "},{"kind":"identifier","text":"SQLiteStorageEngine"}],"abstract":[{"type":"text","text":"A "},{"type":"reference","isActive":true,"identifier":"doc:\/\/Bodega\/documentation\/Bodega\/StorageEngine"},{"type":"text","text":" based on an SQLite database."}],"identifier":"doc:\/\/Bodega\/documentation\/Bodega\/SQLiteStorageEngine","kind":"symbol","type":"topic","navigatorTitle":[{"kind":"identifier","text":"SQLiteStorageEngine"}],"url":"\/documentation\/bodega\/sqlitestorageengine"}}}