From: ts Date: 2000-03-31T17:19:23+02:00 Subject: [ruby-talk:02299] Re: setter() for local variables >>>>> "Y" == Yukihiro Matsumoto writes: Y> def []=(k,v) Y> @tbl[k] = v Y> @db[::Mashal::dump(k)] = ::Mashal::dump(v) Y> end I must do the same for def [], in theory, i.e. def [](k) @tbl[k] = @db[::Marshal::dump(k)] @tbl[k] end otherwise I lost the possibility to have transaction. A littele example (I don't like the syntax actually, it's copied from the C interface but perhaps there is a better way of doing it) pigeon% cat b.rb #!/usr/bin/ruby require "bdb" env = BDB::Env.new("/tmp", ["DB_DATA_DIR /tmp"], BDB::CREATE | BDB::INIT_MPOOL | BDB::INIT_TXN) db = env.open_db(BDB::BTREE, "aa", nil, BDB::CREATE, 0644) db["a"] = 12 a, b = env.begin(db) b["a"] = 24 c, d = a.begin(db) d["a"] = 36 p db["a"] c.abort p db["a"] a.abort p db["a"] pigeon% b.rb "36" "24" "12" pigeon% This mean that I must manage the database and an hash (or an array for DB_RECNO, DB_QUEUE). I lost the advantage of BerkeleyDB, no ? Guy Decoux