For a while now I've had a package called Prevayler that basically ran as a local disk based object oriented database. It was really easy to use - read: completely transparent. But it did have its quirks:
- While it was called Prevayler, it didn't work like Prevayler
- It couldn't let two images access it at once
- It's garbage collection only worked properly if every object was in memory
- It liked to keep everything in memory, it never forgot stuff back to disk
- It had no unit tests
- It used BOSS files to store the data (good luck if something goes wrong!)
- It didn't have a clear API for schema migration
- It had no indexes
- It did not guarantee ACID
- You could only commit to disk, not other sources like a database
- It did not do transactions
- There was only ever one repository
So I've started a new project called Elephant that will replace Prevayler. I'm intending it to fix up all the issues described above so that it works as a real database. (All except making it work like Prevayler, since the way Prevayler works is plain dumb). It may even perform well - who knows.
This kind of technology is meant to make it easy to start persisting data without getting in to the nitty gritty of a database. It's not intended to replace a database that's going to hold millions of records. But honestly, how often do you make applications like that? Amusingly enough, if Elephant can commit to a database.. then it very well could support millions of records.
I've just published v1.0 of Elephant to the public store. It has unit tests and it has much simpler code. It's also based on Martin McClure's ImmutibilityPolicy framework which will become standard for VisualWorks in the future. Prevayler was incompatible with Martin's framework.
Elephant also can support multiple repositories, which is a bonus. In fact, the tests run in a 'test' repository so that if you have running objects, the testing system will not interrupt your data.
So of the list above, Elephant still has the following to go:
- It can't let two images access it at once
- It doesn't have a clear API for schema migration
- It has no indexes
- It did not guarantee ACID
- You can only commit to disk, not other sources like a database
- It does not do transactions
So the next version, 2.0 will tackle the following issues:
- It can't let two images access it at once
- It doesn't have a clear API for schema migration
- It did not guarantee ACID
- It does not do transactions
Then version 3.0 may tackle the rest of the issues.
I've been talking to Blaine Buxton about Prevayler and Elephant and I think I've convinced him to port the project to Squeak and VA. But it won't be worth him doing that until there is a 2.0 version.
But for now, Elephant is a viable replacement for Prevayler. I'll be using it in a few projects shortly to ensure that it is solid enough to be used as a replacement for Prevayler. My confidence is high as I have unit tests this time. Every thing that goes in to Elephant from here on is pure bonus on top of the old Prevayler feature set.
So how do you use Elephant? Well it's really simple actually. You make a Repository object and tell it where its data goes and that's it:
(myRepository := Repository new) path: 'my-data'.
Now you can call #trunk on it to put stuff in your Repository. Absolutely anything except system data can go in there (ie: classes, blocks, UI stuff, etc).
myRepository trunk at: #settings put: mySettingsObject.
For more detail on how to use it, take a look at the test cases.