flanker icon indicating copy to clipboard operation
flanker copied to clipboard

Cache interface does not work with dict semantics

Open rraval opened this issue 10 years ago • 0 comments

When mail_exchanger_lookup() fails to connect to the mail exchanger for a specific domain, it sets the corresponding cache entry to False (line 149). However, lookup_exchanger_in_cache() looks for the string 'False' to figure out if there was an MX connection failure for a domain in cache.

This asymmetry means that caches that implement proper dict semantics (i.e. not coercing all values to strings unlike the Redis driver) fail miserably. I believe that a simple in memory cache like defaultdict(lambda: None) should just work and not fail with TypeError. This behaviour is also the root cause for https://github.com/mailgun/flanker/pull/31.

rraval avatar Nov 10 '14 21:11 rraval