예제 #1
0
static void _item_replace(struct item *it, struct item *nit) {
    assert(it->magic == ITEM_MAGIC);
    assert(!item_is_slabbed(it));
    assert(nit->magic == ITEM_MAGIC);
    assert(!item_is_slabbed(nit));
    _item_unlink(it);
    _item_link(nit);
}
예제 #2
0
파일: item.c 프로젝트: huayl/pelikan
void
item_insert(struct item *it, const struct bstring *key)
{
    ASSERT(it != NULL && key != NULL);

    item_delete(key);

    _item_link(it);
    log_verb("insert it %p of id %"PRIu8" for key %.*s", it, it->id, key->len,
        key->data);
}
예제 #3
0
struct item *item_alloc(uint8_t id, char *key, uint16_t nkey, int exptime, char *value, uint32_t nbyte) {
    struct item *it, *oit;
    pthread_mutex_lock(&cache_lock);
    it = _item_alloc(id, key, nkey, exptime, value, nbyte);
    if (it == NULL) return NULL;
    oit = _item_get(key, nkey);
    if (oit != NULL) _item_replace(oit, it);
    else {
    	_item_link(it);
    }
    if (oit != NULL) _item_remove(oit);
    pthread_mutex_unlock(&cache_lock);
    return it;
}