concurrent-dns-cache-0.1.3: Concurrent DNS cache

Safe HaskellNone
LanguageHaskell2010

Network.DNS.Cache

Contents

Description

DNS cache to resolve domains concurrently.

Synopsis

Documentation

data DNSCacheConf Source #

Configuration for DNS cache.

Constructors

DNSCacheConf 

Fields

  • resolvConfs :: [ResolvConf]

    A list of resolvers (cache DNS servers). A domain is resolved by the resolvers concurrently. The first reply is used regardless of success/failure at this moment

  • maxConcurrency :: Int

    Capability of how many domains can be resolved concurrently

  • minTTL :: NominalDiffTime

    The minimum bound of cache duration for success replies in seconds.

  • maxTTL :: NominalDiffTime

    The maximum bound of cache duration for success replies in seconds.

  • negativeTTL :: NominalDiffTime

    The cache duration for failure replies in seconds.

data DNSCache Source #

An abstract data for DNS cache. Cached domains are expired every 10 seconds according to their TTL.

withDNSCache :: (MonadBaseControl IO m, MonadIO m) => DNSCacheConf -> (DNSCache -> m a) -> m a Source #

A basic function to create DNS cache. Domains should be resolved in the function of the second argument.

Looking up

lookup :: DNSCache -> Domain -> IO (Maybe HostAddress) Source #

Lookup Domain in the cache. If not exist, queries are sent to DNS servers and resolved IP addresses are cached.

lookupCache :: DNSCache -> Domain -> IO (Maybe HostAddress) Source #

Lookup Domain only in the cache.

Resolving

data Result Source #

Information of positive result.

Constructors

Hit HostAddress

An address obtained from the cache.

Resolved HostAddress

An address resolved from cache DNS servers.

Numeric HostAddress

Specified domain is IP address. So, it is converted into a numeric address.

Instances
Eq Result Source # 
Instance details

Defined in Network.DNS.Cache.Types

Methods

(==) :: Result -> Result -> Bool #

(/=) :: Result -> Result -> Bool #

Show Result Source # 
Instance details

Defined in Network.DNS.Cache.Types

resolve :: DNSCache -> Domain -> IO (Either DNSError Result) Source #

Lookup Domain in the cache. If not exist, queries are sent to DNS servers and resolved IP addresses are cached.

resolveCache :: DNSCache -> Domain -> IO (Maybe (Either DNSError Result)) Source #

Lookup Domain only in the cache.

Waiting

wait :: DNSCache -> (Int -> Bool) -> IO () Source #

Wait until the predicate in the second argument is satisfied. The predicate are given the number of the current resolving domains.

For instance, if you ensure that no resolvings are going on:

wait cache (== 0)

If you want to ensure that capability of concurrent resolving is not full:

wait cache (< maxCon)

where maxCon represents maxConcurrency in DNSCacheConf.