322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
|
# File 'ext/native_server.c', line 322
VALUE mc_set(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_set(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 {
return throw_error(&result);
}
}
|