Re: [Dproxy-devel] dproxy 1.x
Brought to you by:
mattpratt
From: Andreas H. <hof...@in...> - 2000-02-10 02:31:58
|
qu...@ba... wrote: > > On Wed, 9 Feb 2000, Andreas Hofmeister wrote: > > <SNIP> > > FIFO is not the best cache strategy one can think of, but it would work. > > I suggest a reference count in the dproxy file ie: > Ok I would suggest the following memory cache implementation with or whithout refresh 1. The mem-cache is a linked list of entries 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. 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. 4. we can not check for the entry on the DNS server! If we get an entry from the DNS, that entry will only be added to the disk cache. Only if it is referenced again, it will get into to the memory. 5a. (no refresh) if an entry from the cache expires, it is removed. 5b. (refresh) on each purge run on the mem cache, we decrease the reference count. If an entry is expired and the reference count is greater 0, we put that entry into a 'refresh' list. Names in the refresh list will be refreshed in a separate process and written into the disk cache. 6. We do not refresh entries in the disk cache. 7. After startup, the memory cache is empty. 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. - We don't have linear access patterns that are longer than the cache size, this would lead to 'cache trashing'. - refresh with that implementation will work, as long as the system (and dproxy) are started and connected at least once in every 'cache_min_time' interval, - the TTL of a mem cache entry and a disk cache entry are always the same. 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. Ciao Andreas |