1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
|
# File 'ext/lmdb_ext/lmdb_ext.c', line 1138
static VALUE database_put(int argc, VALUE *argv, VALUE self) {
DATABASE(self, database);
if (!active_txn(database->env))
return call_with_transaction(database->env, self, "put", argc, argv, 0);
VALUE vkey, vval, option_hash = Qnil;
rb_scan_args_kw(RB_SCAN_ARGS_LAST_HASH_KEYWORDS,
argc, argv, "20:", &vkey, &vval, &option_hash);
rb_scan_args(argc, argv, "20:", &vkey, &vval, &option_hash);
int flags = 0;
if (!NIL_P(option_hash))
rb_hash_foreach(option_hash, (int (*)(ANYARGS))database_put_flags,
(VALUE)&flags);
vkey = StringValue(vkey);
vval = StringValue(vval);
MDB_val key, value;
key.mv_size = RSTRING_LEN(vkey);
key.mv_data = RSTRING_PTR(vkey);
value.mv_size = RSTRING_LEN(vval);
value.mv_data = RSTRING_PTR(vval);
check(mdb_put(need_txn(database->env), database->dbi, &key, &value, flags));
return Qnil;
}
|