ANN: CDBStore, a lightweight persistent dictionary
ANN: CDBStore, a lightweight persistent dictionary
- Subject: ANN: CDBStore, a lightweight persistent dictionary
- From: Jens Alfke <email@hidden>
- Date: Fri, 2 May 2008 18:07:35 -0700
http://mooseyard.com/projects/CDBStore/
CDBStore is a file-backed persistent dictionary. You can store and
retrieve values using keys; only the values you ask for get read from
the file, and only modified values get written back to the file. The
values can be arbitrary archivable NSObjects. The keys are, by
default, limited to NSData, but you can easily support other types of
keys by overriding one method.
CDBStore is a kind of middle ground between simple property-lists or
archived objects, and CoreData. There's a very large empty space
there, and I kept getting annoyed by having to cobble together yet
another bit of code to read and write a dictionary from a file. And
I'm not the only one, as evidenced by this message:
On 2 May '08, at 3:29 PM, Angel Todorov wrote:
I want to serialize in an archive a set of objects (big ones) that are
instances of a class which implements NSCoding. On deserialization,
I don't
want the whole archive to be loaded in memory, but only the object
for the
*key* that I am requesting.
Behind the scenes, CDBStore uses CDB, or "Constant DataBase", a simple
persistence library. CDB is very efficient: usually no more than two
reads to fetch any value, and the file is memory-mapped so it takes
advantage of the kernel's caching. It's also very reliable: it never
updates a file in place, so its files cannot get corrupted on a system
crash the way SQLite or Berkeley DB databases can. On the other hand,
it won't be nearly as efficient for large rapidly-updated data sets.
I've been using CDBStore for a few months now in the app I'm
developing. I can't claim it's fully complete, but it's been working
very well for me. It's released under a BSD license, so feel free to
use it anywhere.
—Jens
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden