> > There is another style of persistance which is to persist the
> > object via some sort of serialisation and then record any 
> > changes in a log, and then taking full snapshots of the 
> > system every now and then.
> > 
> > This is the basis of the prevayler concept.  Having played
> > with it a little it's quite neat and robust.  The .net 
> > prevayler it is quite _transluscent_ with the only 
> > requirement being a container that inherits from 
> > MarshalByRefObject, the objects being [Serializable] along 
> > with some startup glue code to get the persistence engine up 
> > and running (which is about 3 lines).
> 
>         Perhaps I miss something obvious, but how can a 
> system be robust if it keeps objects in memory without 
> persisting them directly to a persistent storage like a DB 
> which has transaction logs and real persistent storage like 
> files in disk? 

Because each time the object is acted on the changes are put in a
transaction log, it is very similar to a database in that way.  If the
system crashes the last snapshot is loaded and then all the operations
in the transaction log are rolled forward so that the system is in a
known state.

>         Another thing I have a problem with is the fact that 
> if you keep an entity E, which is changed and persisted 
> (transaction is over, object is finalized) (but only in 
> memory), in memory somewhere, another box targeting the same 
> database will not see that changed entity E and will work 
> with the older one, which can and will lead to undesired 
> results. This is for example the case in desktop applications 
> targeting the same database or in a webfarm.

And just like a database you need some form of broker (aka DAL) that
will deal these entities out to a business layer.  The prevayler system
is a replacement for a database and being in-memory it is much quicker.

However I would be very leery implementing it in a mission-critical app,
but for most things it would be fine, for example I am currently using
it as the user and session mamnagement store for a web site (my personal
one) where I think this software (like mysql) is at an advantage.  It
has low overhead, it reduces the amount of work that I need to do, and
is free while still being (AFAICT) robust.

Check out the Prevayler FAQ
http://www.prevayler.org/wiki.jsp?topic=PrevalenceSkepticalFAQ a choice
quote about the persistence is from the top
>>>
Do you mean I can simply have my objects in RAM and forget all that
database hassle? 
That's right. 
        
Are you crazy? What if there's a system crash? 
To avoid losing data, every night, or in any reasonable period, your
system server saves a snapshot of all business objects to a file using
plain object serialization. 
        
What about the changes occurred since the last snapshot was taken? Won't
the system lose those in a crash? 
No. All commands received from the system's clients are converted into
serializable objects by the server. Before being applied to the business
objects, each command is serialized and written to a log file. During
crash recovery, first, the system retrieves its last saved state from
the snapshot file. Then, it reads the commands from the log files
created since the snapshot was taken. These commands are simply applied
to the business objects exactly as if they had just come from the
system's clients. The system is then back in the state it was just
before the crash and is ready to run.
<<<

Chris

===================================
This list is hosted by DevelopMentor�  http://www.develop.com
Some .NET courses you may be interested in:

NEW! Guerrilla ASP.NET, 17 May 2004, in Los Angeles
http://www.develop.com/courses/gaspdotnetls

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to