Category Archives: Microsoft

Create a simple cache in C# .NET

Here is a little sample of code I have written to simulate a cache, wich write the data every second on disk in the background in a dedicted thread.

Using this class Engine, you can write data to the internal dictionary and keep it safe because the database is written to disk… I do not have handled the reload of the data in the ctor… Here the client program who write any number of values you want:

If I run the console application using different values, here is the result:

D:\Dev\MyCache\ConsoleApp1\bin\Debug>ConsoleApp1.exe 10
Count: 10
Time elapsed set: 0 ms
Time elapsed get: 0 ms
Writing DB…
Writing DB OK

D:\Dev\MyCache\ConsoleApp1\bin\Debug>ConsoleApp1.exe 100
Count: 100
Time elapsed set: 0 ms
Time elapsed get: 0 ms
Writing DB…
Writing DB OK

D:\Dev\MyCache\ConsoleApp1\bin\Debug>ConsoleApp1.exe 1000
Count: 1000
Time elapsed set: 1 ms
Time elapsed get: 1 ms
Writing DB…
Writing DB OK

D:\Dev\MyCache\ConsoleApp1\bin\Debug>ConsoleApp1.exe 10000
Count: 10000
Time elapsed set: 7 ms
Time elapsed get: 13 ms
Writing DB…
Writing DB OK

D:\Dev\MyCache\ConsoleApp1\bin\Debug>ConsoleApp1.exe 100000
Count: 100000
Time elapsed set: 98 ms
Time elapsed get: 140 ms
Writing DB…
Writing DB OK

D:\Dev\MyCache\ConsoleApp1\bin\Debug>ConsoleApp1.exe 1000000
Count: 1000000
Writing DB…
Writing DB OK
Time elapsed set: 3656 ms
Time elapsed get: 4023 ms
Writing DB…
Writing DB OK

Source code here:


Article in Technical Magazine Programmez N° 218 – May 2018

In May 2018, you will discover a technical article How to build under 64 bits environment. It contains tips&tricks for handling the migration because the source code will not compile as easy you can think…


LMDB for Windows

When I discovered the fantastic history of LMDB, It fascinated me. For a R&D projet, we need to present something that looks sexy and with a strong architecture. I proposed to study LMDB and bring to it the distributed engine and the clustering stuff with nodes. There are plenty ways of acheiveing this.

First, OpenLDAP-LMDB need to be ported on the Windows platform. It’s a C based code so there are no some many changes to fix for building on Windows. There was a path concat that made some problems but it’s defined as constants so I fixed it rapidly. I put it in Github after the operation was done.:

I was able to build a static lib for LMDB. But in Windows, we love shared modules called DLL so I have to put some little things on the source code to enable loading shared modules DLL (Dynamic Link Library).

#define LMDBWINDOWSDLL_API __declspec(dllexport)
#define LMDBWINDOWSDLL_API __declspec(dllimport)

With theses expanded macros, it can export functions. Every headers and bodys need to be decorated. Here is the explaination. When you build the library, you define de constant LMDBWINDOWSDLL_EXPORTS in the project settings then every macros instruct the compiler to export the functions. When you build an application who needs the dll, the macro is expanded as an import operation and at the link phase, you need to link with the little stub to attach the library.

If you are new to Windows DLLs making, check this portion of doc on MSDN:

Enter in the world of NoSQL engines

Sometimes ago, I had to discover a source code, as is. It was a database engine. A big software, powered by C/C++ using linux tools. I always install cygwin on my machines so there was no problem. Tools where Bison, lex and sed. Some bash scripts to put files on common folders & some other stuff. The storage engine was powered with LMDB. It’s the fastest engine on the market, they said in a README.MD. There was also a data structure that was associated with a registered patent.

I have read a lot of wikipedia on NoSQL engines and I have inspected a lot of source code like LMDB and Redis. It’s all about C, it’s brutal and very efficient. It fascinates me. And so what for ?

I currently work on a R&D project to put a NoSQL engine on a Windows service and install it on a Docker image and run it in Azure Container Instances (ACI). As a Micrcosoft partner, my company has to work with Azure and win competencies. Because it’s a R&D project, we have ambitions : make a Redis like software. With distributed features. We want superior performance versus DocumentDB. It will be powered by LMDB. More to come in coming weeks. Stay tuned.

Make your own IDE in C++

For the december edition of programmez n°213, I have written an article and developped an IDE using MFC and C++.

Mission at Sydev 21 Burgundy Area

This week, I will deliver 5 days about a hot session on C++ Windows Programming using MFC.

Goal: plan to migrate a Win32 C messages app to a MFC app with Ribbon, Properties Grid and more.


Updating Scintilla open-source project and Naughter’s wrappers and Boost 1.63

When I have updated Scintilla’s wrappers written by Naughter, I encountered compilation errors…
This the MFC class view that operates with the scintilla control. I need to update that class too. But first of all, I need to update Boost. Current version is 1.63. Just compile it with bjam. Classic stuff. Result is in stage\lib folder.


For the moment I use Boost only for serialization stuff for XML stuff.


Here is a XML file:


Boost serialization is not easy because it is designed that data has to be read by a Boost app…