Re: [Dproxy-devel] dproxy 1.x
Brought to you by:
mattpratt
From: Benjamin C. <clo...@lu...> - 2000-02-10 03:15:57
|
On Thu, 10 Feb 2000, Andreas Hofmeister wrote: > Ok I would suggest the following memory cache implementation with or > whithout refresh I like the idea! > 2. Every time we search and find an entry in the mem-cache, we move it > to the front of the list. > 2a. (refresh) if an entry was referenced, we increase a reference count. We are still going to have the problem of sharing the list between processes. I suggest that the parent searches the ll, then disk, and returns the appropriate entry if found. Else we fork off the child to do the dns, since it may timeout. If we have the ip/name the delay shouldn't be that noticable so I think this would work well. > 3. if we can not find the entry in the mem cache, we search it in the > disk cache and the dhcp file (in that order), if we find it there, we > will add it to the mem cache as the first element. If there are too many > entries in the mem cache, we remove the last element from the list. If we find the entry in the disk cache and move it to memory we should probably also remove it/mark it invalid from the disk cache. We may end up with data inconsistency otherwise. > 6. We do not refresh entries in the disk cache. What happens to expired entries in the disk cache? On next refrence we move the to the ll and inc the refcount. However these may be way out of date. I think if we get an entry from the disk cache and the TTL has expired, refresh them add to ll. > Hardware people sometimes call this a 'write through 1st level cache'. > IMO this implementation will work well, if some conditions are meet : > > - The cache is 'large enough', all heavily used entries can be kept in > memory. I think this is already somewhat done. The reference count will force new entries in the ll so the ll will grow with the demand and shrink as the demand drops (ref count ==0) > - the TTL of a mem cache entry and a disk cache entry are always the > same. Removing the entry from the disk cache solves this problem. We may just want to mark it invalid (TTL=-1?)and have the purge routine rewrite the file when we go off the net. > detail alternatives : > > - Instead of a reference count, one could use the LRU time > - Instead of starting with an empty cache, one could fill up the cache > with the last > 'mem_cache_size' entries from the disk cache. Reloading the whole mem cache may be a little pointless. I think just reload the entries with a reference count > x where x is a defined value. Oh, who wan't to write what? Cheers, Benjamin PS: sorry emails to the address quakevr@bandi... will bounce - firewalled |