hi, developers
I am a Chinese student. I am very interested in the cache implement of
"TS", and I have read TS's code for several days. I note that TS write a
item with a "full-index" mode: throug the CacheKey to find
part->segment->bucket and write in a part of the item to a dir. If
conflicting, there is a link "dir->next" to store all data having same
index. But when the cache is full, TS will execute the code in
"cachedir.cc":
void
freelist_clean(int s, Part * part)
{
dir_clean_segment(s, part);
if (part->header->freelist[s])
return;
Warning("cache directory overflow on '%s' segment %d, purging...",
part->path, s);
int n = 0;
Dir *seg = dir_segment(s, part);
for (int bi = 0; bi < part->buckets; bi++) {
Dir *b = dir_bucket(bi, seg);
for (int l = 0; l < DIR_DEPTH; l++) {
Dir *e = dir_bucket_row(b, l);
if (dir_head(e) && !(n++ % 10)) {
CACHE_DEC_DIR_USED(part->mutex);
dir_set_offset(e, 0); // delete
}
}
}
dir_clean_segment(s, part);
}
this means TS just remove some head dirs by traversing, not care the heat of
the dir and not remove other dirs belong to the same item of the head dir.
The document says "When the cache is full, Traffic Server removes stale
data, ensuring that the most requested objects are kept on-hand and fresh.".
I want to consult how TS implement it and where stores the hit-number of one
item.
And, is there some more document about the TS architecture?
Thanks a lot.
Flame Yu