Version 1.1: Improvements & Changes, Some Breaking #8
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request has many changes, and some of them are breaking. This is work that's important for Bodega (and Boutique), improving upon and fixing some assumptions I'd made earlier in the development lifecycle of Bodega, before there even was a Boutique.
Aside from improvements this version will lay the foundation for a version 2.0 of Bodega and Boutique, one that will offer some very significant and much-needed performance improvements. Having gone through the exercise of optimizing most anything that can provide a reasonable boost in performance, now 85% of the time Bodega spends on reading or writing is filesystem-based operations, many of which are ones I can't tune. To remedy this Bodega 2.0 will offer a database-powered variant of the underlying Storage (currently
DiskStorage
), while leavingObjectStorage
unchanged. This will mean that your code doesn't have to change, but may require data that you can't repopulate to be manually migrated.You will have the ability to stay on 1.x versions of the library if you don't want to make any changes, but Bodega 2.0 will provide a new
DatabaseStorage
option that uses SQLite under the hood and provides 400% faster performance. This is especially useful for apps that have large data sets (10,000+ objects), as many production apps do, and will be the default storage option for Boutique 2.0.Now that we know why these changes are being made, here are the changes in this pull request.
subdirectory
parameters. The subdirectory is complicated, error-prone, and in practice doesn't have much use. When I first started working on Bodega I was using subdirectories to shard objects, but now you can easily create a newObjectStorage
orDiskStorage
pointing to a subdirectory to replicate the functionality thesubdirectory
parameter offers. The benefit is a much simpler and clearer API, and removes much surface area for bugs such as this code.Removing
.lastAccessed()
fromObjectStorage
. WhenObjectStorage
was guaranteed to have aDiskStorage
under the hood we could call the underlyingDiskStorage
's version of this method to figure out when the object was last accessed. But going forwardObjectStorage
is no longer guaranteed to useDiskStorage
, for example as we use will useDatabaseStorage
in the future. The method will still remain available onDiskStorage
, with no changes tolastModified()
orcreationDate()
.Adding
applicationSupportDirectory()
on the Mac. If you have suggestions for other useful directories please let me know.Adding a new type,
FileManager.Directory
, to provide a type-safe replacement for the folders inDiskStorage+Directories
. The initializer forObjectStorage
orDiskStorage
now looks likeinit(directory: Directory)
rather thaninit(storagePath: URL)
, which allows for shorter, type-safe, and file-system safe initializers such asDiskStorage(directory: .documents(appendingPath: "Notes"))
.Fixing documentation to match all of these changes, please let me know if I missed anything!
I would love to hear all of your feedback about all of these changes, short-term or long-term!