{"primaryContentSections":[{"kind":"declarations","declarations":[{"tokens":[{"kind":"keyword","text":"protocol"},{"kind":"text","text":" "},{"kind":"identifier","text":"StorageEngine"},{"kind":"text","text":" : "},{"kind":"typeIdentifier","text":"Actor","preciseIdentifier":"s:ScA"}],"languages":["swift"],"platforms":["macOS"]}]},{"kind":"content","content":[{"anchor":"overview","level":2,"type":"heading","text":"Overview"},{"type":"paragraph","inlineContent":[{"type":"text","text":"A "},{"type":"reference","isActive":true,"identifier":"doc:\/\/Bodega\/documentation\/Bodega\/StorageEngine"},{"type":"text","text":" is a construct you can build that plugs into "},{"type":"reference","isActive":true,"identifier":"doc:\/\/Bodega\/documentation\/Bodega\/ObjectStorage"},{"type":"text","text":" "},{"type":"text","text":"to use for persisting data."}]},{"type":"paragraph","inlineContent":[{"type":"text","text":"This library has two implementations of "},{"type":"reference","isActive":true,"identifier":"doc:\/\/Bodega\/documentation\/Bodega\/StorageEngine"},{"type":"text","text":", "},{"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":"."},{"type":"text","text":" "},{"type":"text","text":"Both of these can serve as inspiration if you have your own persistence mechanism (such as Realm, CoreData, etc)."}]},{"type":"paragraph","inlineContent":[{"type":"reference","isActive":true,"identifier":"doc:\/\/Bodega\/documentation\/Bodega\/DiskStorageEngine"},{"type":"text","text":" takes "},{"type":"codeVoice","code":"Data"},{"type":"text","text":" and saves it to disk using file system operations."},{"type":"text","text":" "},{"type":"reference","isActive":true,"identifier":"doc:\/\/Bodega\/documentation\/Bodega\/SQLiteStorageEngine"},{"type":"text","text":" takes "},{"type":"codeVoice","code":"Data"},{"type":"text","text":" and saves it to an SQLite database under the hood."}]},{"type":"paragraph","inlineContent":[{"type":"text","text":"If you have your own way of storing data then you can refer to "},{"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":" "},{"type":"text","text":"for inspiration, but all you need to do is conform to the "},{"type":"reference","isActive":true,"identifier":"doc:\/\/Bodega\/documentation\/Bodega\/StorageEngine"},{"type":"text","text":" protocol"},{"type":"text","text":" "},{"type":"text","text":"and initialize "},{"type":"reference","isActive":true,"identifier":"doc:\/\/Bodega\/documentation\/Bodega\/ObjectStorage"},{"type":"text","text":" with that storage."}]}]}],"schemaVersion":{"major":0,"minor":2,"patch":0},"sections":[],"variants":[{"paths":["\/documentation\/bodega\/storageengine"],"traits":[{"interfaceLanguage":"swift"}]}],"relationshipsSections":[{"identifiers":["doc:\/\/Bodega\/s8SendableP","doc:\/\/Bodega\/ScA"],"kind":"relationships","title":"Inherits From","type":"inheritsFrom"},{"identifiers":["doc:\/\/Bodega\/documentation\/Bodega\/DiskStorageEngine","doc:\/\/Bodega\/documentation\/Bodega\/SQLiteStorageEngine"],"kind":"relationships","title":"Conforming Types","type":"conformingTypes"}],"identifier":{"url":"doc:\/\/Bodega\/documentation\/Bodega\/StorageEngine","interfaceLanguage":"swift"},"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."}],"kind":"symbol","metadata":{"fragments":[{"kind":"keyword","text":"protocol"},{"kind":"text","text":" "},{"kind":"identifier","text":"StorageEngine"}],"title":"StorageEngine","roleHeading":"Protocol","role":"symbol","symbolKind":"protocol","externalID":"s:6Bodega13StorageEngineP","modules":[{"name":"Bodega"}],"navigatorTitle":[{"kind":"identifier","text":"StorageEngine"}]},"hierarchy":{"paths":[["doc:\/\/Bodega\/documentation\/Bodega"]]},"topicSections":[{"title":"Instance Methods","identifiers":["doc:\/\/Bodega\/documentation\/Bodega\/StorageEngine\/allKeys()","doc:\/\/Bodega\/documentation\/Bodega\/StorageEngine\/createdAt(key:)","doc:\/\/Bodega\/documentation\/Bodega\/StorageEngine\/keyCount()","doc:\/\/Bodega\/documentation\/Bodega\/StorageEngine\/keyExists(_:)","doc:\/\/Bodega\/documentation\/Bodega\/StorageEngine\/read(key:)","doc:\/\/Bodega\/documentation\/Bodega\/StorageEngine\/read(keys:)-90zkt","doc:\/\/Bodega\/documentation\/Bodega\/StorageEngine\/readAllData()-1gzc6","doc:\/\/Bodega\/documentation\/Bodega\/StorageEngine\/readAllDataAndKeys()-9a3kk","doc:\/\/Bodega\/documentation\/Bodega\/StorageEngine\/readDataAndKeys(keys:)","doc:\/\/Bodega\/documentation\/Bodega\/StorageEngine\/remove(key:)","doc:\/\/Bodega\/documentation\/Bodega\/StorageEngine\/remove(keys:)-2lqqc","doc:\/\/Bodega\/documentation\/Bodega\/StorageEngine\/removeAllData()","doc:\/\/Bodega\/documentation\/Bodega\/StorageEngine\/updatedAt(key:)","doc:\/\/Bodega\/documentation\/Bodega\/StorageEngine\/write(_:)","doc:\/\/Bodega\/documentation\/Bodega\/StorageEngine\/write(_:key:)"]}],"references":{"doc://Bodega/documentation/Bodega/StorageEngine/read(keys:)-90zkt":{"defaultImplementations":1,"role":"symbol","title":"read(keys:)","fragments":[{"kind":"keyword","text":"func"},{"kind":"text","text":" "},{"kind":"identifier","text":"read"},{"kind":"text","text":"("},{"kind":"externalParam","text":"keys"},{"kind":"text","text":": ["},{"kind":"typeIdentifier","text":"CacheKey","preciseIdentifier":"s:6Bodega8CacheKeyV"},{"kind":"text","text":"]) "},{"kind":"keyword","text":"async"},{"kind":"text","text":" -> ["},{"kind":"typeIdentifier","text":"Data","preciseIdentifier":"s:10Foundation4DataV"},{"kind":"text","text":"]"}],"abstract":[],"identifier":"doc:\/\/Bodega\/documentation\/Bodega\/StorageEngine\/read(keys:)-90zkt","kind":"symbol","required":true,"type":"topic","url":"\/documentation\/bodega\/storageengine\/read(keys:)-90zkt"},"doc://Bodega/documentation/Bodega/StorageEngine/keyCount()":{"role":"symbol","title":"keyCount()","fragments":[{"kind":"keyword","text":"func"},{"kind":"text","text":" "},{"kind":"identifier","text":"keyCount"},{"kind":"text","text":"() "},{"kind":"keyword","text":"async"},{"kind":"text","text":" -> "},{"kind":"typeIdentifier","text":"Int","preciseIdentifier":"s:Si"}],"abstract":[],"identifier":"doc:\/\/Bodega\/documentation\/Bodega\/StorageEngine\/keyCount()","kind":"symbol","required":true,"type":"topic","url":"\/documentation\/bodega\/storageengine\/keycount()"},"doc://Bodega/documentation/Bodega/StorageEngine/readAllData()-1gzc6":{"defaultImplementations":1,"role":"symbol","title":"readAllData()","fragments":[{"kind":"keyword","text":"func"},{"kind":"text","text":" "},{"kind":"identifier","text":"readAllData"},{"kind":"text","text":"() "},{"kind":"keyword","text":"async"},{"kind":"text","text":" -> ["},{"kind":"typeIdentifier","text":"Data","preciseIdentifier":"s:10Foundation4DataV"},{"kind":"text","text":"]"}],"abstract":[],"identifier":"doc:\/\/Bodega\/documentation\/Bodega\/StorageEngine\/readAllData()-1gzc6","kind":"symbol","required":true,"type":"topic","url":"\/documentation\/bodega\/storageengine\/readalldata()-1gzc6"},"doc://Bodega/documentation/Bodega/StorageEngine/keyExists(_:)":{"role":"symbol","title":"keyExists(_:)","fragments":[{"kind":"keyword","text":"func"},{"kind":"text","text":" "},{"kind":"identifier","text":"keyExists"},{"kind":"text","text":"("},{"kind":"typeIdentifier","text":"CacheKey","preciseIdentifier":"s:6Bodega8CacheKeyV"},{"kind":"text","text":") "},{"kind":"keyword","text":"async"},{"kind":"text","text":" -> "},{"kind":"typeIdentifier","text":"Bool","preciseIdentifier":"s:Sb"}],"abstract":[],"identifier":"doc:\/\/Bodega\/documentation\/Bodega\/StorageEngine\/keyExists(_:)","kind":"symbol","required":true,"type":"topic","url":"\/documentation\/bodega\/storageengine\/keyexists(_:)"},"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"},"doc://Bodega/documentation/Bodega/StorageEngine/readDataAndKeys(keys:)":{"role":"symbol","title":"readDataAndKeys(keys:)","fragments":[{"kind":"keyword","text":"func"},{"kind":"text","text":" "},{"kind":"identifier","text":"readDataAndKeys"},{"kind":"text","text":"("},{"kind":"externalParam","text":"keys"},{"kind":"text","text":": ["},{"kind":"typeIdentifier","text":"CacheKey","preciseIdentifier":"s:6Bodega8CacheKeyV"},{"kind":"text","text":"]) "},{"kind":"keyword","text":"async"},{"kind":"text","text":" -> [(key"},{"kind":"text","text":": "},{"kind":"typeIdentifier","text":"CacheKey","preciseIdentifier":"s:6Bodega8CacheKeyV"},{"kind":"text","text":", data"},{"kind":"text","text":": "},{"kind":"typeIdentifier","text":"Data","preciseIdentifier":"s:10Foundation4DataV"},{"kind":"text","text":")]"}],"abstract":[],"identifier":"doc:\/\/Bodega\/documentation\/Bodega\/StorageEngine\/readDataAndKeys(keys:)","kind":"symbol","required":true,"type":"topic","url":"\/documentation\/bodega\/storageengine\/readdataandkeys(keys:)"},"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/StorageEngine/remove(keys:)-2lqqc":{"defaultImplementations":1,"role":"symbol","title":"remove(keys:)","fragments":[{"kind":"keyword","text":"func"},{"kind":"text","text":" "},{"kind":"identifier","text":"remove"},{"kind":"text","text":"("},{"kind":"externalParam","text":"keys"},{"kind":"text","text":": ["},{"kind":"typeIdentifier","text":"CacheKey","preciseIdentifier":"s:6Bodega8CacheKeyV"},{"kind":"text","text":"]) "},{"kind":"keyword","text":"async"},{"kind":"text","text":" "},{"kind":"keyword","text":"throws"}],"abstract":[],"identifier":"doc:\/\/Bodega\/documentation\/Bodega\/StorageEngine\/remove(keys:)-2lqqc","kind":"symbol","required":true,"type":"topic","url":"\/documentation\/bodega\/storageengine\/remove(keys:)-2lqqc"},"doc://Bodega/documentation/Bodega/StorageEngine/write(_:)":{"role":"symbol","title":"write(_:)","fragments":[{"kind":"keyword","text":"func"},{"kind":"text","text":" "},{"kind":"identifier","text":"write"},{"kind":"text","text":"([(key"},{"kind":"text","text":": "},{"kind":"typeIdentifier","text":"CacheKey","preciseIdentifier":"s:6Bodega8CacheKeyV"},{"kind":"text","text":", data"},{"kind":"text","text":": "},{"kind":"typeIdentifier","text":"Data","preciseIdentifier":"s:10Foundation4DataV"},{"kind":"text","text":")]) "},{"kind":"keyword","text":"async"},{"kind":"text","text":" "},{"kind":"keyword","text":"throws"}],"abstract":[],"identifier":"doc:\/\/Bodega\/documentation\/Bodega\/StorageEngine\/write(_:)","kind":"symbol","required":true,"type":"topic","url":"\/documentation\/bodega\/storageengine\/write(_:)"},"doc://Bodega/s8SendableP":{"type":"unresolvable","title":"Swift.Sendable","identifier":"doc:\/\/Bodega\/s8SendableP"},"doc://Bodega/documentation/Bodega/StorageEngine/readAllDataAndKeys()-9a3kk":{"defaultImplementations":1,"role":"symbol","title":"readAllDataAndKeys()","fragments":[{"kind":"keyword","text":"func"},{"kind":"text","text":" "},{"kind":"identifier","text":"readAllDataAndKeys"},{"kind":"text","text":"() "},{"kind":"keyword","text":"async"},{"kind":"text","text":" -> [(key"},{"kind":"text","text":": "},{"kind":"typeIdentifier","text":"CacheKey","preciseIdentifier":"s:6Bodega8CacheKeyV"},{"kind":"text","text":", data"},{"kind":"text","text":": "},{"kind":"typeIdentifier","text":"Data","preciseIdentifier":"s:10Foundation4DataV"},{"kind":"text","text":")]"}],"abstract":[],"identifier":"doc:\/\/Bodega\/documentation\/Bodega\/StorageEngine\/readAllDataAndKeys()-9a3kk","kind":"symbol","required":true,"type":"topic","url":"\/documentation\/bodega\/storageengine\/readalldataandkeys()-9a3kk"},"doc://Bodega/documentation/Bodega/StorageEngine/updatedAt(key:)":{"role":"symbol","title":"updatedAt(key:)","fragments":[{"kind":"keyword","text":"func"},{"kind":"text","text":" "},{"kind":"identifier","text":"updatedAt"},{"kind":"text","text":"("},{"kind":"externalParam","text":"key"},{"kind":"text","text":": "},{"kind":"typeIdentifier","text":"CacheKey","preciseIdentifier":"s:6Bodega8CacheKeyV"},{"kind":"text","text":") "},{"kind":"keyword","text":"async"},{"kind":"text","text":" -> "},{"kind":"typeIdentifier","text":"Date","preciseIdentifier":"s:10Foundation4DateV"},{"kind":"text","text":"?"}],"abstract":[],"identifier":"doc:\/\/Bodega\/documentation\/Bodega\/StorageEngine\/updatedAt(key:)","kind":"symbol","required":true,"type":"topic","url":"\/documentation\/bodega\/storageengine\/updatedat(key:)"},"doc://Bodega/documentation/Bodega/StorageEngine/createdAt(key:)":{"role":"symbol","title":"createdAt(key:)","fragments":[{"kind":"keyword","text":"func"},{"kind":"text","text":" "},{"kind":"identifier","text":"createdAt"},{"kind":"text","text":"("},{"kind":"externalParam","text":"key"},{"kind":"text","text":": "},{"kind":"typeIdentifier","text":"CacheKey","preciseIdentifier":"s:6Bodega8CacheKeyV"},{"kind":"text","text":") "},{"kind":"keyword","text":"async"},{"kind":"text","text":" -> "},{"kind":"typeIdentifier","text":"Date","preciseIdentifier":"s:10Foundation4DateV"},{"kind":"text","text":"?"}],"abstract":[],"identifier":"doc:\/\/Bodega\/documentation\/Bodega\/StorageEngine\/createdAt(key:)","kind":"symbol","required":true,"type":"topic","url":"\/documentation\/bodega\/storageengine\/createdat(key:)"},"doc://Bodega/documentation/Bodega/StorageEngine/remove(key:)":{"role":"symbol","title":"remove(key:)","fragments":[{"kind":"keyword","text":"func"},{"kind":"text","text":" "},{"kind":"identifier","text":"remove"},{"kind":"text","text":"("},{"kind":"externalParam","text":"key"},{"kind":"text","text":": "},{"kind":"typeIdentifier","text":"CacheKey","preciseIdentifier":"s:6Bodega8CacheKeyV"},{"kind":"text","text":") "},{"kind":"keyword","text":"async"},{"kind":"text","text":" "},{"kind":"keyword","text":"throws"}],"abstract":[],"identifier":"doc:\/\/Bodega\/documentation\/Bodega\/StorageEngine\/remove(key:)","kind":"symbol","required":true,"type":"topic","url":"\/documentation\/bodega\/storageengine\/remove(key:)"},"doc://Bodega/documentation/Bodega/StorageEngine/allKeys()":{"role":"symbol","title":"allKeys()","fragments":[{"kind":"keyword","text":"func"},{"kind":"text","text":" "},{"kind":"identifier","text":"allKeys"},{"kind":"text","text":"() "},{"kind":"keyword","text":"async"},{"kind":"text","text":" -> ["},{"kind":"typeIdentifier","text":"CacheKey","preciseIdentifier":"s:6Bodega8CacheKeyV"},{"kind":"text","text":"]"}],"abstract":[],"identifier":"doc:\/\/Bodega\/documentation\/Bodega\/StorageEngine\/allKeys()","kind":"symbol","required":true,"type":"topic","url":"\/documentation\/bodega\/storageengine\/allkeys()"},"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":{"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/StorageEngine/read(key:)":{"role":"symbol","title":"read(key:)","fragments":[{"kind":"keyword","text":"func"},{"kind":"text","text":" "},{"kind":"identifier","text":"read"},{"kind":"text","text":"("},{"kind":"externalParam","text":"key"},{"kind":"text","text":": "},{"kind":"typeIdentifier","text":"CacheKey","preciseIdentifier":"s:6Bodega8CacheKeyV"},{"kind":"text","text":") "},{"kind":"keyword","text":"async"},{"kind":"text","text":" -> "},{"kind":"typeIdentifier","text":"Data","preciseIdentifier":"s:10Foundation4DataV"},{"kind":"text","text":"?"}],"abstract":[],"identifier":"doc:\/\/Bodega\/documentation\/Bodega\/StorageEngine\/read(key:)","kind":"symbol","required":true,"type":"topic","url":"\/documentation\/bodega\/storageengine\/read(key:)"},"doc://Bodega/documentation/Bodega/StorageEngine/write(_:key:)":{"role":"symbol","title":"write(_:key:)","fragments":[{"kind":"keyword","text":"func"},{"kind":"text","text":" "},{"kind":"identifier","text":"write"},{"kind":"text","text":"("},{"kind":"typeIdentifier","text":"Data","preciseIdentifier":"s:10Foundation4DataV"},{"kind":"text","text":", "},{"kind":"externalParam","text":"key"},{"kind":"text","text":": "},{"kind":"typeIdentifier","text":"CacheKey","preciseIdentifier":"s:6Bodega8CacheKeyV"},{"kind":"text","text":") "},{"kind":"keyword","text":"async"},{"kind":"text","text":" "},{"kind":"keyword","text":"throws"}],"abstract":[],"identifier":"doc:\/\/Bodega\/documentation\/Bodega\/StorageEngine\/write(_:key:)","kind":"symbol","required":true,"type":"topic","url":"\/documentation\/bodega\/storageengine\/write(_:key:)"},"doc://Bodega/ScA":{"type":"unresolvable","title":"_Concurrency.Actor","identifier":"doc:\/\/Bodega\/ScA"},"doc://Bodega/documentation/Bodega/StorageEngine/removeAllData()":{"role":"symbol","title":"removeAllData()","fragments":[{"kind":"keyword","text":"func"},{"kind":"text","text":" "},{"kind":"identifier","text":"removeAllData"},{"kind":"text","text":"() "},{"kind":"keyword","text":"async"},{"kind":"text","text":" "},{"kind":"keyword","text":"throws"}],"abstract":[],"identifier":"doc:\/\/Bodega\/documentation\/Bodega\/StorageEngine\/removeAllData()","kind":"symbol","required":true,"type":"topic","url":"\/documentation\/bodega\/storageengine\/removealldata()"}}}