News for hackers. Stuff that matters.
Re:LevelDB: a fast and lightweight key/value database library by Emore on Sunday May 08, 2011 @07:35PM (#2526985)
@sghemawat: Are you planning on implementing atomic CAS operations?
Re:LevelDB: a fast and lightweight key/value database library by sghemawat on Monday May 09, 2011 @01:00AM (#2527623)
We have no such plans. The library is designed so that concurrency control is outside its scope. If I needed it for an application, I might consider using some application level code that looks like:

    bool CAS(db, key, oldvalue, newvalue) {
      lock some mutex;
      read key's value from db;
      bool result = (value == oldvalue);
      if (result) write key=>newvalue to db;
      unlock;
      return result;
    }
This should be not much slower than any hard-wired CAS we could provide from inside leveldb.