MCPcopy Create free account
hub / github.com/apache/trafficserver / put

Method put

src/iocore/hostdb/P_RefCountCache.h:216–250  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

214
215template <class C>
216void
217RefCountCachePartition<C>::put(uint64_t key, C *item, int size, time_t expire_time)
218{
219 Metrics::Counter::increment(this->rsb->refcountcache_total_inserts);
220 size += sizeof(C);
221 // Remove any colliding entries
222 this->erase(key);
223
224 // if we are full, and can't make space-- then don't store the item
225 if (this->is_full() && !this->make_space_for(size)) {
226 Dbg(dbg_ctl, "partition %d is full-- not storing item key=%" PRIu64, this->part_num, key);
227 Metrics::Counter::increment(this->rsb->refcountcache_total_failed_inserts);
228 return;
229 }
230
231 // Create our value-- which has a ref to the `item`
232 RefCountCacheHashEntry *val = RefCountCacheHashEntry::alloc();
233 val->set(item, key, size, expire_time);
234
235 // add expiry_entry to expiry queue, if the expire time is positive (otherwise it means don't expire)
236 if (expire_time >= 0) {
237 Dbg(dbg_ctl, "partition %d adding entry with expire_time=%" PRIdMAX, this->part_num, expire_time);
238 PriorityQueueEntry<RefCountCacheHashEntry *> *expiry_entry = expiryQueueEntry.alloc();
239 new (expiry_entry) PriorityQueueEntry<RefCountCacheHashEntry *>(val);
240 expiry_queue.push(expiry_entry);
241 val->expiry_entry = expiry_entry;
242 }
243
244 // add the item to the map
245 this->item_map.insert(val);
246 this->size += val->meta.size;
247 this->items++;
248 Metrics::Gauge::increment(this->rsb->refcountcache_current_size, static_cast<int64_t>(val->meta.size));
249 Metrics::Gauge::increment(this->rsb->refcountcache_current_items);
250}
251
252template <class C>
253void

Callers 6

fillCacheFunction · 0.45
testRefcountingFunction · 0.45
testclearFunction · 0.45
testFunction · 0.45
dnsEventMethod · 0.45

Calls 9

eraseMethod · 0.95
is_fullMethod · 0.95
make_space_forMethod · 0.95
partition_for_keyMethod · 0.95
incrementFunction · 0.85
setMethod · 0.45
allocMethod · 0.45
pushMethod · 0.45
insertMethod · 0.45

Tested by 4

fillCacheFunction · 0.36
testRefcountingFunction · 0.36
testclearFunction · 0.36
testFunction · 0.36