namecache redesign

tridge at samba.org tridge at samba.org
Sun Sep 1 16:06:00 GMT 2002


> Tridge, what do you think about having a timestamp in as part of the
> cache structure? 

yes, timeouts are essential.

This was the API I proposed:

BOOL gencache_add(const char *key, const char *value, time_t timeout);
BOOL gencache_del(const char *key);
BOOL gencache_get(const char *key, char **value, time_t *timeout);
void gencache_iterate(void (*fn)(const char *key, const char *value, time_t time out));

notice the 'timeout' parameters? This would be stored along with each
cache entry. I'm not at all fussed about the format this is stored in.

The simplest way to use the timeout would be to just fail a
gencache_get() for any entry that has expired (and auto-delete it),
and I think that should be the default behaviour.

If we want to get a bit fancier then we should have a 'refresh' time
and a 'expiry' time, in a similar fashion to DNS. The idea is that if
the refresh time has been reached then we try to re-fetch the
information but if the re-fetch fails then we use the cached entry. We
only delete the cached entry when it reaches its expiry time.

I'd be happy for an initial implementation to just have a single
expiry time (like the API I posted) but if whoever implements this
wants to put in the two level expiry then that would be great.

Cheers, Tridge



More information about the samba-technical mailing list