465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
|
# File 'ext/native_server.c', line 465
VALUE mc_replace(int argc, VALUE *argv, VALUE self) {
memcached_st *mc;
VALUE key, value, expiry, flags;
static memcached_return_t result;
Data_Get_Struct(self, memcached_st, mc);
rb_scan_args(argc, argv, "22", &key, &value, &expiry, &flags);
key = StringValue(key);
if (!use_binary(mc)) key = escape_key(key, NULL);
value = StringValue(value);
result = memcached_replace(mc, RSTRING_PTR(key), RSTRING_LEN(key), RSTRING_PTR(value), RSTRING_LEN(value),
RTEST(expiry) ? NUM2UINT(expiry) : 0,
RTEST(flags) ? NUM2UINT(flags) : 0);
if (result == MEMCACHED_SUCCESS) {
return value;
} else if(result == MEMCACHED_NOTSTORED) {
return Qnil;
} else {
return throw_error(&result);
}
}
|