class XBAD
Public Class Methods
new(p1, p2, p3)
click to toggle source
static VALUE XBAD_init(VALUE self, VALUE _shmid, VALUE _hash_bits, VALUE _item_size ) { int shmid = NUM2INT(_shmid); int item_size = NUM2INT(_item_size); int hash_bits = NUM2INT(_hash_bits); struct shared_pool *sp = get_shared_pool(self); shared_pool_init(sp,shmid,hash_bits,item_size); return self; }
Public Instance Methods
find(p1)
click to toggle source
static VALUE XBAD_find(VALUE self, VALUE key) { VALUE ret = Qnil; struct shared_pool *sp = get_shared_pool(self); struct item *item = t_find_and_lock(sp,RSTRING_PTR(key),RSTRING_LEN(key)); if (item) { ret = rb_str_new(ITEM_BLOB(item),item->blob_len); shared_pool_unlock_item(item); } return ret; }
store(p1, p2, p3)
click to toggle source
static VALUE XBAD_store(VALUE self, VALUE key, VALUE value, VALUE _expire_after) { die_unless_string(key); die_unless_string(value); struct shared_pool *sp = get_shared_pool(self); int expire_after = NUM2INT(_expire_after); if (t_add(sp,RSTRING_PTR(key),RSTRING_LEN(key),RSTRING_PTR(value),RSTRING_LEN(value),expire_after) != 0) rb_raise(rb_eArgError,"failed to store"); return value; }
store_and_broadcast(p1, p2, p3, p4)
click to toggle source
static VALUE XBAD_store_and_broadcast(VALUE self, VALUE key, VALUE value, VALUE _expire_after,VALUE _port) { die_unless_string(key); die_unless_string(value); struct shared_pool *sp = get_shared_pool(self); int expire_after = NUM2INT(_expire_after); unsigned short port = NUM2INT(_port); struct in_addr ip = { .s_addr = htonl(0xffffffff) }; if (t_add_and_sent_to(sp,RSTRING_PTR(key),RSTRING_LEN(key),RSTRING_PTR(value),RSTRING_LEN(value),expire_after,ip,port) != 0) rb_raise(rb_eArgError,"failed to store and broadcast"); return value; }