tisdagen den 28:e juni 2011

LiveDB + WebSockets via XSockets - lightning fast!

 

liveDB + XSockets = true

Yesterday we made a few lab's where we combined the liveDB in-memory-database engine for .NET and XSockets.

logo_small (1)We found out that liveDB hand in hand with XSockets is a fine recipe,it brings a lightning fast data access, the possibility work with plain objects as we do in XSockets the liveDB engine transparently take care of persistence and consistency.

The liveDB technique is really simple. The entire data model is maintained in memory, you are able define commands that modify the model, write queries towards the model using LINQ for an example.

Those commands and queries are invoked by the WebSocketHandler designed to for this purpose, this will be illustrated in the video shown below as well as we will create a example if this an “bundle” I in the next NuGet package of XSockets.

At the WebSocket Server startup or after some kind of failure, the liveDB engine restores the in-memory database to its previous state.

This is a code snippet WebSocket handler Event that broadcasts all entities from the model to a WebSocket Client, in this case a list of entities.

/// <summary>
/// List all Questionings
/// </summary>
[HandlerEvent("ListQuestioning")]
public void List()
{
   
try
   
{
       
var xSocketEvent = new XSocketEvent<List<LiveDB.Entities.Questioning>>
                               
{
                                   
Event = "OnListQuestioning",
                                   
Data =
                                       
LiveDbInstance<QuestioningModel>.GetInstance().Execute(
                                           
LiveDB.Queries.Questioning.All())
                               
};
       
// send to the socket invoked the event
        XNode.SendTo(xSocketEvent.Serialize());
   
}
   
catch (Exception)
   
{
       
throw;
   
}
}

You can read more about WebSocketHandler and the “Handler Event” attribute at http://xsockets.net/Documentation/Index.

LiveDB + WebSockets (Using XSockets)

 Links

 

Magnus Thor

0 kommentarer:

Skicka en kommentar