[Haskell-cafe] pure Haskell database
manlio_perillo at libero.it
Thu Sep 25 17:09:11 EDT 2008
Graham Fawcett ha scritto:
> On Wed, Sep 24, 2008 at 5:17 PM, Manlio Perillo
> <manlio_perillo at libero.it> wrote:
>> I need a simple, concurrent safe, database, written in Haskell.
>> A database with the interface of Data.Map would be great, since what I need
>> to to is atomically increment some integer values, and I would like to avoid
>> to use SQLite.
> If that's the entire requirement, and you're looking for something
> really fast, perhaps you could use a shared-memory region between the
> processes (your keys would map to addresses in shared memory), and use
> a compare-and-set algorithm to handle the atomic increments.
> If you're on Intel/Itanium, I believe there's a CMPXCHG instruction
> that will do atomic compare-and-set on a memory address, and I'm not
> sure you could get much faster than that. :-)
I have an early draft of this type of database (written in D).
Operations on integers use CMPXCHG, and for other operations a simple
spin lock (implemented following the implementation in Nginx) is used.
The problem is that it is a simple shared array!
This means that you need to know in advance the data index in the array;
for some type of applications this is true, I was trying to implement
that database for using it in my HTTP Digest authentication
order to improve security, using "not so restful" support in the RFC 2617.
More information about the Haskell-Cafe