Rollback Mechanism?

Jan 26, 2011 at 8:14 PM

Hi Guys,

I just started with the Sterling Engine and find it really intuitiv and easy to use. So first of all - Great work guys!

But for a database guy like me, I'm really missing a feature. How can I Rollback the changes in memory? As I understand, all changes are done in memory and stored to the isolated storage when calling the Flush() method. But what can I do, if I want to revert that changes done in memory? If I think about a database, I really miss a Rollback() function in order to rollback all accumulated changes.

How can I achive this?

Thx in advance
- Gerhard

Coordinator
Jan 26, 2011 at 8:38 PM

Sterling does not support transactions currently and I'm not sure if it will in the future - again, the idea is to fill a gap and find a balance between something extremely lightweight for serialization versus a fully relational database with clustered indexes, atomic transactions, etc.

It's not entirely true that Sterling stores everything in memory. It actually persists all data changes to the disk. It's only the indexes and keys that are stored in memory, and those are persisted with flush. So there is no way currently to rollback a change. I would suggest deserializing two copies of the target object and make your modifications then null or revert to the original if you want to rollback. I.E.:

var rollbackObj = SterlingDatabase.Load<MyClass>(1);

var modifiedObj = SterlingDatabase.Load<MyClass>(1);

... do stuff ...

SterlingDatabase.Save(modifiedObj);

OOPS! I need to rollback ...

SterlingDatabase.Save(rollbackObj);

... or I don't ...

rollbackObj = modifiedObj;